Queer European MD passionate about IT
浏览代码

Merge pull request #93 from dataquestio/long/optim/tidyr/john/dec11

gather > pivot_longer in the RMD
John Aoga 5 年之前
父节点
当前提交
4e64aa471b
共有 1 个文件被更改,包括 7 次插入2 次删除
  1. 7 2
      Mission327Solutions.Rmd

+ 7 - 2
Mission327Solutions.Rmd

@@ -100,8 +100,13 @@ map2(x_var, y_var, create_scatter)
 Reshape the data so that you can investigate differences in student, parent, and teacher responses to survey questions.
 Reshape the data so that you can investigate differences in student, parent, and teacher responses to survey questions.
 
 
 ```{r}
 ```{r}
-combined_survey_gather <- combined_survey %>%                         
-  gather(key = "survey_question", value = score, saf_p_11:aca_tot_11)
+# combined_survey_gather <- combined_survey %>%
+#   gather(key = "survey_question", value = score, saf_p_11:aca_tot_11)
+
+combined_survey_gather <- combined_survey %>%
+  pivot_longer(cols = saf_p_11:aca_tot_11,
+               names_to = "survey_question",
+               values_to = "score")
 ```
 ```
 
 
 Use `str_sub()` to create new variables, `response_type` and `question`, from the `survey_question` variable.
 Use `str_sub()` to create new variables, `response_type` and `question`, from the `survey_question` variable.