From a292dbda7287eddffd15a8e7a91574727f4141a6 Mon Sep 17 00:00:00 2001 From: zee-zhijun Date: Tue, 27 Sep 2016 19:14:06 -0400 Subject: [PATCH 1/3] Submit Class 7 Exercise. --- .gitignore | 3 +++ Class 7 Instructions.Rmd | 21 +++++++++++++-------- class7.Rproj | 13 +++++++++++++ 3 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 .gitignore create mode 100644 class7.Rproj diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..807ea25 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.Rproj.user +.Rhistory +.RData diff --git a/Class 7 Instructions.Rmd b/Class 7 Instructions.Rmd index 5ae641a..f8bab9a 100644 --- a/Class 7 Instructions.Rmd +++ b/Class 7 Instructions.Rmd @@ -18,7 +18,7 @@ library(tidyr, dplyr) ##Upload wide format instructor data (instructor_activity_wide.csv) ```{r} -data_wide <- read.table("~/Documents/NYU/EDCT2550/Assignments/Assignment 3/instructor_activity_wide.csv", sep = ",", header = TRUE) +data_wide <- read.table("~/Documents/EDM2016/gitHub/Class7_data_tidying/instructor_activity_wide.csv", sep = ",", header = TRUE) #Now view the data you have uploaded and notice how its structure: each variable is a date and each row is a type of measure. View(data_wide) @@ -54,12 +54,15 @@ The spread function requires the following input: ```{r} instructor_data <- spread(data_long, variables, measure) +View(instructor_data) ``` ##Now we have a workable instructor data set!The next step is to create a workable student data set. Upload the data "student_activity.csv". View your file once you have uploaded it and then draw on a piece of paper the structure that you want before you attempt to code it. Write the code you use in the chunk below. (Hint: you can do it in one step) ```{r} - +student <- read.table("~/Documents/EDM2016/gitHub/Class7_data_tidying/student_activity.csv", sep = ",", header = TRUE) +View(student) +student_data <- spread(student, variable, measure) ``` ##Now that you have workable student data set, subset it to create a data set that only includes data from the second class. @@ -75,7 +78,7 @@ student_data_2 <- dplyr::filter(student_data, date == 20160204) Now subset the student_activity data frame to create a data frame that only includes students who have sat at table 4. Write your code in the following chunk: ```{r} - +student_data_2_table4 <- dplyr::filter(student_data_2, table == 4) ``` ##Make a new variable @@ -89,7 +92,7 @@ instructor_data <- dplyr::mutate(instructor_data, total_sleep = s_deep + s_light Now, refering to the cheat sheet, create a data frame called "instructor_sleep" that contains ONLY the total_sleep variable. Write your code in the following code chunk: ```{r} - +instructor_sleep <- dplyr::select(instructor_data, total_sleep) ``` Now, we can combine several commands together to create a new variable that contains a grouping. The following code creates a weekly grouping variable called "week" in the instructor data set: @@ -100,7 +103,7 @@ instructor_data <- dplyr::mutate(instructor_data, week = dplyr::ntile(date, 3)) Create the same variables for the student data frame, write your code in the code chunk below: ```{r} - +student_data <- dplyr::mutate(student_data, week = dplyr::ntile(date, 3)) ``` ##Sumaraizing @@ -117,7 +120,8 @@ student_data %>% dplyr::group_by(date) %>% dplyr::summarise(mean(motivation)) Create two new data sets using this method. One that sumarizes average motivation for students for each week (student_week) and another than sumarizes "m_active_time" for the instructor per week (instructor_week). Write your code in the following chunk: ```{r} - +student_week <- student_data %>% dplyr::group_by(week) %>% dplyr::summarise(mean(motivation)) +instructor_week <- instructor_data %>% dplyr::group_by(week) %>% dplyr::summarise(mean(m_active_time)) ``` ##Merging @@ -131,7 +135,8 @@ merge <- dplyr::full_join(instructor_week, student_week, "week") Visualize the relationship between these two variables (mean motivation and mean instructor activity) with the "plot" command and then run a Pearson correlation test (hint: cor.test()). Write the code for the these commands below: ```{r} - +plot (merge$`mean(m_active_time)`, merge$`mean(motivation)`, xlab="Average Instructor Active Time by Week", ylab = "Average Student Motivation by Week", main = "Relationship between Active Time \n and Motivation") +cor.test(merge$`mean(m_active_time)`,merge$`mean(motivation)`) ``` -Fnally save your markdown document and your plot to this folder and comit, push and pull your repo to submit. +Finally save your markdown document and your plot to this folder and comit, push and pull your repo to submit. diff --git a/class7.Rproj b/class7.Rproj new file mode 100644 index 0000000..8e3c2eb --- /dev/null +++ b/class7.Rproj @@ -0,0 +1,13 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX From 9579e279072ec50b910eebaae5716465a50fef47 Mon Sep 17 00:00:00 2001 From: zee-zhijun Date: Tue, 27 Sep 2016 19:19:41 -0400 Subject: [PATCH 2/3] Corrected file name and extracted plot as pdf. --- Class 7 Instructions.Rmd | 4 ++-- plot_active_time_motivation.pdf | Bin 0 -> 4814 bytes 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 plot_active_time_motivation.pdf diff --git a/Class 7 Instructions.Rmd b/Class 7 Instructions.Rmd index f8bab9a..a4b39e2 100644 --- a/Class 7 Instructions.Rmd +++ b/Class 7 Instructions.Rmd @@ -18,7 +18,7 @@ library(tidyr, dplyr) ##Upload wide format instructor data (instructor_activity_wide.csv) ```{r} -data_wide <- read.table("~/Documents/EDM2016/gitHub/Class7_data_tidying/instructor_activity_wide.csv", sep = ",", header = TRUE) +data_wide <- read.table("~/Documents/EDM2016/class7/instructor_activity_wide.csv", sep = ",", header = TRUE) #Now view the data you have uploaded and notice how its structure: each variable is a date and each row is a type of measure. View(data_wide) @@ -60,7 +60,7 @@ View(instructor_data) ##Now we have a workable instructor data set!The next step is to create a workable student data set. Upload the data "student_activity.csv". View your file once you have uploaded it and then draw on a piece of paper the structure that you want before you attempt to code it. Write the code you use in the chunk below. (Hint: you can do it in one step) ```{r} -student <- read.table("~/Documents/EDM2016/gitHub/Class7_data_tidying/student_activity.csv", sep = ",", header = TRUE) +student <- read.table("~/Documents/EDM2016/class7/student_activity.csv", sep = ",", header = TRUE) View(student) student_data <- spread(student, variable, measure) ``` diff --git a/plot_active_time_motivation.pdf b/plot_active_time_motivation.pdf new file mode 100644 index 0000000000000000000000000000000000000000..b29ae1ce57acd8e06b8df81b5d0c860c11aea584 GIT binary patch literal 4814 zcmb7Ic|6qX_ZJ~kDqET;pJc80%nXJR$u6=lV;dP`Ft;%?%~Hrt2)QVV?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ATCH 3/3] change variable x and y in the plot --- Class 7 Instructions.Rmd | 4 ++-- ...ion.pdf => plot_motivation_active_time.pdf | Bin 4814 -> 4827 bytes 2 files changed, 2 insertions(+), 2 deletions(-) rename plot_active_time_motivation.pdf => plot_motivation_active_time.pdf (79%) diff --git a/Class 7 Instructions.Rmd b/Class 7 Instructions.Rmd index a4b39e2..0052a13 100644 --- a/Class 7 Instructions.Rmd +++ b/Class 7 Instructions.Rmd @@ -135,8 +135,8 @@ merge <- dplyr::full_join(instructor_week, student_week, "week") Visualize the relationship between these two variables (mean motivation and mean instructor activity) with the "plot" command and then run a Pearson correlation test (hint: cor.test()). Write the code for the these commands below: ```{r} -plot (merge$`mean(m_active_time)`, merge$`mean(motivation)`, xlab="Average Instructor Active Time by Week", ylab = "Average Student Motivation by Week", main = "Relationship between Active Time \n and Motivation") -cor.test(merge$`mean(m_active_time)`,merge$`mean(motivation)`) +plot (merge$`mean(motivation)`, merge$`mean(m_active_time)`, ylab="Average Instructor Active Time by Week", xlab = "Average Student Motivation by Week", main = "Relationship between Motivation \n and Active Time") +cor.test(merge$`mean(motivation)`, merge$`mean(m_active_time)`) ``` Finally save your markdown document and your plot to this folder and comit, push and pull your repo to submit. diff --git a/plot_active_time_motivation.pdf b/plot_motivation_active_time.pdf similarity index 79% rename from plot_active_time_motivation.pdf rename to plot_motivation_active_time.pdf index b29ae1ce57acd8e06b8df81b5d0c860c11aea584..6fe69b39b62d0dbf6ae81768f799a0eea2e68712 100644 GIT binary patch delta 927 zcmX@7dRujZHH(p@iP=PZ2?!m1m&w#@vK6CR{cQ(5vny>c1e{(oaeeER^_S?U{&CY+m(K?y$`GJRmajPDGy}CSj#dT5lV-h|0 zU+-EgVXz@ifbH<(=UW@wUkSxIRHtyQadFL8yTBE2ZL!$FCsMcm_DuS}Ir8YD^B=3r zzO{y}ZTtSJ{@Jug5g{_?URJKDFlgxJI>0$aY|9l5i8XHAY`yI2f!0i7w#>^X-jus? z@XCT~%-I*kV%Z9>XUq~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