Module #8 Assignment
For this week's assignment, I worked with the given dataset containing four variables for a set of students. The dataset included both males and females, and it also included ages, grades, and names. The assignment tasked me with importing the file into R, calculating the mean grade by sex, filtering the dataset for names containing the letter "i", and export the results into a csv file.
The first step I did was importing the dataset into R using the read.table(). After importing the data, I used the ddply() function from the pylr packaged that we were tasked with installing for this assignment to group the dataset by sex and calculate the average of the grade column. This summarized the comparison between male and female students instead of having to look through them individually. After generating the mean, we get the following output:
Sex Grade_Average
1 Female 86.9375
2 Male 80.2500
After that I converted teh dataset into a datarame and filtered using the functions subset() along with grepl(). I looked for names cotaining the letter "i" in the Name column, making sure to ignore uppercases and lowercases. This created the final filtered dataset containing only names containing the letter "i". After that I did the next step which was to im[oprt this dataset to a csv file using the write.csv() funciton.Filtered names containing "i": > i_students
Name Age Sex Grade
3 Lauri 21 Female 90
4 Leonie 21 Female 91
6 Mikaela 20 Female 69
8 Aiko 24 Female 97
9 Tiffaney 21 Female 78
10 Corina 23 Female 81
11 Petronila 23 Female 98
12 Alecia 20 Female 87
13 Shemika 23 Female 97
15 Deloris 21 Female 67
17 Eboni 20 Female 84
18 Delfina 19 Female 93
19 Ernestina 19 Female 93
20 Milo 19 Male 67
This assignmened helped me pratice my skills when it comes to iproting data, grouping data by different categories, filtering and exporting results to csv files. Working with csv files in the past I have ran into issues so its also refreshing to go back and pratice those skills.
Comments
Post a Comment