Assignment #8: Input/Output, String Manipulation, and the plyr Package

 R script: 


GitHub link: Assignment_08_Input_Output_String_Manipulation

Outputs for each step: 



Descriptions of each step:

  1. Import dataI loaded the Assignment 6 dataset file using file.choose() so the file can be selected manually. It then ensures the data is made into a data frame with proper headers and types.
  2. Load plyr and compute mean of grade by sex: I installed and loaded in the package 'plyr', grouped the rows by 'Sex', then calculated the average 'Grade' to summarize the performance by gender.
  3. Write grouped means to text file:  I exported the summary to a tab-delimited "gender_mean.txt" file making the results easy to read.
  4. Filter names containing "i": Using grepl("i", Name, ignore.case=TRUE), I selected only students whose names contained "i" or "I" to practice filtering.
  5. Export names only to a CSV: I saved the filtered names to "i_students.csv" to produce a compact output using the requirements from the previous step. 
  6. Export full filtered rows to a CSV: I wrote the full filtered data frame to "i_students_full.csv" to ensure that all columns are preserved.
  7. Confirm outputs exist: I checked that "gender_mean.txt", "i_students.csv", and "i_students_full.csv" exist in the working directory to confirm each file-write step was successful. 

Reading

  • Matloff, N. M. (2011). The Art of R Programming, Chapters 9–10 (pp. 207–231).
  • Wickham, H. (2015). R Packages: Organize, Test, Document, and Share Your Code, Chapters 2–3 (pp. 27–31).

Comments

Popular posts from this blog

Assignment #5: Matrix Algebra in R

Assignment #3: Analyzing 2016 data “Poll” Data in R

Assignment #4: Visualizing and Interpreting Hospital Patient Data