Week 8: Input/Output, string manipulation and plyr package

Week 8: Input/output, string manipulation and plyr package


    This week was interesting, and the concepts covered within were quite complex this week, seeing code I've never seen before to alter csv files in ways I haven't had the chance to. I had issues downloading the file however, as it didn't wish to save properly, having instead to copy the info into a notepad file, save as all files, and manually type .csv at the end of the file.  However, in the end I got it done, the variable names may be a little wonky as a result, but the code is functional, and I will explain line by line what is going on. The code is available on my GitHub here, and I will upload the csv also.


This is the first few lines of my program, with the first two simply reading in necessary libraries for the program to function, the third reading the csv data (file that I created) into the variable assignment8dataset and then we group the dataset by "sex" (gender), calculate the average grade of each group (male/female grades) and then adds that mean back to the dataframe. 


The first line is creating a text file on my computer, saving the student averages and separating the information in the documents with commas. The line after creates a new dataset that only retains the names that have the letter "i" in it. And the final sentence or line of code simply creates another textfile to my computer with that information (names that have the letter "i" in it"). The results of which can be seen here:

Above you can see that all the students with a name containing the letter "i", 14 of the 20 original observations remain. Only one male in the dataset had a name containing the letter "i", which is something of note. 

The above is the file showing the grouped data, that is the file showing the grouped averages of the genders as well, allowing you to see if the grade the individual received was better or worse than the average of their gender peers. In simpler less convoluted words, you can check the average grade against that of the average male if they're male, or female if they're female. For example, Lauri Scored higher than the average woman, and Raul scored slightly under the average male. 

This week's assignments and lectures were a pleasure as always, I hope I fulfilled the assignment requirements and the little hiccup I had with the file formatting being weird was easily circumvented by the copying of and saving of a new file with the same information, lain out as was intended. I continue looking forward to future assignments, and again enjoyed this weeks coursework.




Comments

Popular posts from this blog

Week 4: Programming Structure in R