Input/Output, String Manipulation and plyr package(Assignment 8)
Greetings Professor,
In this assignment #8, I learnt many ways to process data and also found about the file.choose() function as it allows us to select the file and analyze the data without required location. In this assignment, I have to read and analyze the given dataset.
At first I installed the required packages and libraries by using the code:
> install.packages("pryr")
> require(pryr)
>require(ISLR)
>require(boot)
>install.packages("plyr")
>library(data.table)
>library(plyr) And now to calculate the 'mean' for the category "Sex" I used the code:
And then I given the dataset into R and to view the data by using code:
> Assignment.6.Dataset.1 <- read.csv("C:/Users/chara/Downloads/Assignment 6 Dataset-1.txt")
> View(Assignment.6.Dataset.1)
And now to calculate the 'mean' for the category "Sex" I used the code:
> x = ddply(Assignment.6.Dataset.1, "Sex", transform, Grade.Average=mean(Grade)) > x
To for the Sorted Average and I wrote the data to a .csv file using code:
> write.table(x,"Sorted_Average", sep = ",")
In this step I filtered out the students by their names contain the letter "i" and save the data in a separate .csv file by using the code:
> y= subset(Assignment.6.Dataset.1, grepl("i", Assignment.6.Dataset.1$Name, ignore.case = T)) > y
And finally wrote this file into a .csv file by using code:
> write.table(y,"subset", sep = ",")
The code and the final results posted in the GitHub. This is my GitHub Repository link:
https://github.com/Jahnavi193/Assignment8#assignment8
Thank you.
Comments
Post a Comment