Guest User

Untitled

a guest
Jul 17th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.84 KB | None | 0 0
  1. ---
  2. title: "Edgewood project"
  3. author: "Duy Phan"
  4. date: "June 19, 2018"
  5. output: html_document
  6. ---
  7. Install openxlsx package
  8. ```{r}
  9. #install.packages("openxlsx")
  10. #install.packages("prettyR")
  11. #install.packages("psych")
  12. #install.packages("reshape")
  13. #install.packages("reshape2")
  14. #install.packages("tidyverse")
  15. library("tidyverse")
  16. library("reshape2")
  17. library("reshape")
  18. library("prettyR")
  19. library("openxlsx")
  20. library("psych")
  21. ```
  22. Setting the working directory. (!) Pay attention to the direction of the slash in the directory.
  23. read the xlsx file
  24. ```{r}
  25. setwd("D:/Box Sync/5. Summer 2018/CRI Summer 2018/R/Edgewood project")
  26. dat <- read.xlsx("SIS_Edgewood_Date_Numerical.xlsx", colNames = TRUE, na.strings = c("na","blank","na "))
  27. ```
  28. Make a copy of the file in csv
  29. ```{r}
  30. write.csv(dat, "dat1.csv", row.names = FALSE)
  31. dat1 <- read.csv("dat1.csv")
  32. head(dat1)
  33. ```
  34. View how many observations we have
  35. ```{r}
  36. dim(dat1)
  37. ```
  38. Remove collumn Race
  39. ```{r}
  40. dat2 = subset(dat1, select= -c(Race))
  41. names(dat2)[9]<-"Q1_pre"
  42. ```
  43.  
  44. Remove na data (blank cells)
  45.  
  46. ```{r}
  47. dat2 = na.omit(dat2)
  48. dim(dat2)
  49. head(dat2)
  50. ```
  51. The average for column E "The information [of SIS] provided" (it's on a scale of 1 - 10)
  52. ```{r}
  53. round(mean(dat2$Info.Provided), digit =2)
  54. ```
  55. The average of column F "The presenters" (scale of 1 -10)
  56. ```{r}
  57. round(mean(dat2$Presenters),digit = 2)
  58. ```
  59. 'In column H ["Do you feel more confident about your communication skills following the training?"] the breakdown of students who answered '1' (e.g. yes), '2' (e.g. no) , and '3' (e.g. kinda)
  60. ```{r}
  61. describe.factor(dat2$Feel.more.confident.)
  62. ```
  63. The difference between pre-test (e.g. columns J - T) answers and post-test (e.g. columns U - AE) answers to determine if there were statistically significant changes.
  64. ```{r}
  65. m1p = mean(dat2$Q1_pre)
  66. m2p = mean(dat2$Q2_pre)
  67. m3p = mean(dat2$Q3_pre)
  68. m4p = mean(dat2$Q4_pre)
  69. m5p = mean(dat2$Q5_pre)
  70. m6p = mean(dat2$Q6_pre)
  71. m7p = mean(dat2$Q7_pre)
  72. m8p = mean(dat2$Q8_pre)
  73. m9p = mean(dat2$Q9_pre)
  74. m10p = mean(dat2$Q10_pre)
  75. m11p = mean(dat2$Q11_pre)
  76.  
  77. m1po = mean(dat2$Q1_post)
  78. m2po = mean(dat2$Q2_post)
  79. m3po = mean(dat2$Q3_post)
  80. m4po = mean(dat2$Q4_post)
  81. m5po = mean(dat2$Q5_post)
  82. m6po = mean(dat2$Q6_post)
  83. m7po = mean(dat2$Q7_post)
  84. m8po = mean(dat2$Q8_post)
  85. m9po = mean(dat2$Q9_post)
  86. m10po = mean(dat2$Q10_post)
  87. m11po = mean(dat2$Q11_post)
  88.  
  89. Pre = c(m1p,m2p,m3p,m4p,m5p,m6p,m7p,m8p,m9p,m10p,m11p)
  90. Post= c(m1po,m2po,m3po,m4po,m5po,m6po,m7po,m8po,m9po,m10po,m11po)
  91. Change = Post - Pre
  92. dat3 = data.frame(Pre,Post,Change)
  93. dat3
  94. round(mean(Pre), digit = 2)
  95. round(mean(Post), digit = 2)
  96. round(mean(Change), digit = 2)
  97. ```
  98. ```{r}
  99. #Matt way
  100.  
  101. dat2new = dat2[,9:30]
  102. dat2new = data.frame(meansData = apply(dat2new,2,mean))
  103. dat2new
  104. dat2Post = dat2new[12:22,]
  105. dat2Pre = dat2new[1:11,]
  106. dat2Diff =dat2Post-dat2Pre
  107. dat2Diff
  108. dat3new = data.frame(dat2Pre, dat2Post,dat2Diff)
  109. head(dat3new)
  110. ```
  111.  
  112.  
  113.  
  114.  
  115. Compare average between classes
  116.  
  117. ```{r}
  118. Group.classes = ifelse(dat2$Class..<=2,1,ifelse(dat2$Class..>=4,3,2))
  119. dat2$Group.classes = Group.classes
  120. dat2$Group.classes = as.factor(dat2$Group.classes)
  121. dat4 = aggregate(dat2[,9:30], list(dat2$Group.classes), mean)
  122.  
  123. dat4$ch1 = dat4$Q1_post-dat4$Q1_pre
  124. dat4$ch2 = dat4$Q2_post-dat4$Q2_pre
  125. dat4$ch3 = dat4$Q3_post-dat4$Q3_pre
  126. dat4$ch4 = dat4$Q4_post-dat4$Q4_pre
  127. dat4$ch5 = dat4$Q5_post-dat4$Q5_pre
  128. dat4$ch6 = dat4$Q6_post-dat4$Q6_pre
  129. dat4$ch7 = dat4$Q7_post-dat4$Q7_pre
  130. dat4$ch8 = dat4$Q8_post-dat4$Q8_pre
  131. dat4$ch9 = dat4$Q9_post-dat4$Q9_pre
  132. dat4$ch10 = dat4$Q10_post-dat4$Q10_pre
  133. dat4$ch11 = dat4$Q11_post-dat4$Q11_pre
  134. head(dat4)
  135.  
  136. ```
  137.  
  138. T-test for each questions
  139. ```{r}
  140. t.test(dat2$Q1_post, dat2$Q1_pre, paired = TRUE)
  141. t.test(dat2$Q2_post, dat2$Q2_pre, paired = TRUE)
  142. t.test(dat2$Q3_post, dat2$Q3_pre, paired = TRUE)
  143. t.test(dat2$Q4_post, dat2$Q4_pre, paired = TRUE)
  144. t.test(dat2$Q5_post, dat2$Q5_pre, paired = TRUE)
  145. t.test(dat2$Q6_post, dat2$Q6_pre, paired = TRUE)
  146. t.test(dat2$Q7_post, dat2$Q7_pre, paired = TRUE)
  147. t.test(dat2$Q8_post, dat2$Q8_pre, paired = TRUE)
  148. t.test(dat2$Q9_post, dat2$Q9_pre, paired = TRUE)
  149. t.test(dat2$Q10_post, dat2$Q10_pre, paired = TRUE)
  150. t.test(dat2$Q11_post, dat2$Q11_pre, paired = TRUE)
  151. ```
  152.  
  153. Wilcoxon tests for each questions
  154. ```{r}
  155. wilcox.test(dat2$Q1_post, dat2$Q1_pre, paired = TRUE)
  156. wilcox.test(dat2$Q2_post, dat2$Q2_pre, paired = TRUE)
  157. wilcox.test(dat2$Q3_post, dat2$Q3_pre, paired = TRUE)
  158. wilcox.test(dat2$Q4_post, dat2$Q4_pre, paired = TRUE)
  159. wilcox.test(dat2$Q5_post, dat2$Q5_pre, paired = TRUE)
  160. wilcox.test(dat2$Q6_post, dat2$Q6_pre, paired = TRUE)
  161. wilcox.test(dat2$Q7_post, dat2$Q7_pre, paired = TRUE)
  162. wilcox.test(dat2$Q8_post, dat2$Q8_pre, paired = TRUE)
  163. wilcox.test(dat2$Q9_post, dat2$Q9_pre, paired = TRUE)
  164. wilcox.test(dat2$Q10_post, dat2$Q10_pre, paired = TRUE)
  165. wilcox.test(dat2$Q11_post, dat2$Q11_pre, paired = TRUE)
  166. ```
  167. Comparing overall average responses
  168. ```{r}
  169.  
  170. ```
  171.  
  172.  
  173. Sex and age distribution in classes
  174. ```{r}
  175. dat5 = data.frame(dat2$Sex,dat2$Group.classes)
  176. dat5 = dcast(dat5,dat2.Group.classes~dat2.Sex)
  177. head(dat5)
  178. ```
Add Comment
Please, Sign In to add comment