Input/Output, string manipulation and plyr package
Please 📂 Check out my full code on GitHub!
Dataset:

This assignment gave me a deeper understanding of how R handles data types and why the right approach matters.
My first challenge was realizing that getting the average by the Student gender using the command mean(Sex) didn’t work because [Sex] column is a categorical variable, not numeric. Since this assignment focused on understanding and applying the plyr package, using ddply() function was the better approach for computing group-wise statistics. While the regular mean() function didn’t work, ddply() allowed me to properly group the data and apply transformations in a structured way. Following the professor’s code, I saw firsthand how this command, ddply(Student,”Sex”,transform,Grade.Average=mean(Grade)), efficiently split the dataset, applied the mean function, and combined the results back into a readable format.
This experience reinforced why using the right tools—especially those designed for split-apply-combine operations—makes data manipulation in R much more efficient.
Next, the assignment applied data filtering using subset(), which provided a more efficient way to extract students whose names contained the letter “i.” Instead of manually constructing complex conditions, subset() streamlined the process by combining filtering and pattern matching in a single step.
The last step was to help enhance the file-saving workflow by incorporating file.choose(), which allows users to interactively select a file location rather than relying on hardcoded paths. This small but impactful change made my script more dynamic and user-friendly, reinforcing the importance of building flexible, real-world applications.
Ultimately, this assignment wasn’t just about running code but about making it work smarter. Now, with ddply(), subset(), and file.choose() in my toolkit, I feel one step closer to writing R scripts that not only get the job done but do it with style. 🚀
The final version of my code is now available on GitHub.
References:
Anderson, S (2012) A quick inroduction to plyr. Retrieved from usflearn.instructure.com/courses/
Matloff, N. (2011). The art of R programming: A tour of statistical software design. No Starch Press. Chapter 10-11.