@@ -23,3 +23,362 @@ library(here)
23
23
library(fs)
24
24
root <- here::here()
25
25
root
26
+ knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)
27
+ library(tidyverse)
28
+ library(png)
29
+ library(knitr)
30
+ library(markdown)
31
+ library(lmerTest)
32
+ library(ggthemes)
33
+ library(psych)
34
+ library(magrittr)
35
+ library(langcog)
36
+ knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)
37
+ library(tidyverse)
38
+ library(png)
39
+ library(knitr)
40
+ library(markdown)
41
+ library(lmerTest)
42
+ library(ggthemes)
43
+ library(psych)
44
+ library(magrittr)
45
+ library(tidyboot)
46
+ library(fs)
47
+ library(ggmap)
48
+ library(lubridate)
49
+ source(path(here::here(), "file_paths.R"))
50
+ source(functions_script)
51
+ #Variables to tinker with
52
+ min_completion_time = 8.5
53
+ facebook_ws_raw <-
54
+ readInWebCDI(fb_ws_directory) %>%
55
+ select( #drop a bunch of columns that were screwing up the merge with prolific data
56
+ -opt_out,
57
+ -country,
58
+ -sibling_boolean,
59
+ -sibling_data,
60
+ -sibling_count,
61
+ -caregiver_other
62
+ )
63
+ all_wg_raw <- readInWebCDI(fb_wg_directory)
64
+ prolific_raw <-
65
+ readInWebCDI(prolific_data_directory) %>%
66
+ select(
67
+ colnames(facebook_ws_raw), #drop columns that are prolific specific
68
+ -opt_out, #drop a bunch of columns that were screwing up the merge with facebook data
69
+ -country,
70
+ -sibling_boolean,
71
+ -sibling_data,
72
+ -sibling_count,
73
+ -caregiver_other
74
+ )
75
+ #all of the ws data collected
76
+ all_ws_raw <-
77
+ facebook_ws_raw %>%
78
+ bind_rows(prolific_raw) %>%
79
+ mutate(completed = case_when(
80
+ stringr::str_to_lower(completed) == "true" ~ TRUE,
81
+ stringr::str_to_lower(completed) == "false" ~ FALSE
82
+ ))
83
+ knitr::opts_chunk$set(echo = TRUE)
84
+ library(tidyverse)
85
+ library(png)
86
+ library(knitr)
87
+ library(markdown)
88
+ library(lmerTest)
89
+ library(ggthemes)
90
+ library(psych)
91
+ library(magrittr)
92
+ library(tidyboot)
93
+ library(fs)
94
+ library(ggmap)
95
+ library(lubridate)
96
+ source(path(here::here(), "file_paths.R"))
97
+ source(functions_script)
98
+ #Variables to tinker with
99
+ min_completion_time = 8.5
100
+ all_ws_1 <-
101
+ readInWebCDI(all_data_ws1_path) %>%
102
+ select( #drop a bunch of columns that were screwing up the merge with prolific data
103
+ -opt_out,
104
+ -country,
105
+ -sibling_boolean,
106
+ -sibling_data,
107
+ -sibling_count,
108
+ -caregiver_other
109
+ )
110
+ all_ws_2 <-
111
+ readInWebCDI(all_data_ws2_path) %>%
112
+ select( #drop a bunch of columns that were screwing up the merge with prolific data
113
+ -opt_out,
114
+ -country,
115
+ -sibling_boolean,
116
+ -sibling_data,
117
+ -sibling_count,
118
+ -caregiver_other
119
+ )
120
+ all_ws_raw <-
121
+ all_ws_1 %>%
122
+ bind_rows(all_ws_2) %>%
123
+ mutate(completed = case_when(
124
+ stringr::str_to_lower(completed) == "true" ~ TRUE,
125
+ stringr::str_to_lower(completed) == "false" ~ FALSE
126
+ ))
127
+ all_wg_raw <- readInWebCDI(all_data_wg_path)
128
+ knitr::opts_chunk$set(echo = TRUE)
129
+ library(tidyverse)
130
+ library(png)
131
+ library(knitr)
132
+ library(markdown)
133
+ library(lmerTest)
134
+ library(ggthemes)
135
+ library(psych)
136
+ library(magrittr)
137
+ library(tidyboot)
138
+ library(fs)
139
+ library(ggmap)
140
+ library(lubridate)
141
+ source(path(here::here(), "file_paths.R"))
142
+ source(functions_script)
143
+ #Variables to tinker with
144
+ min_completion_time = 8.5
145
+ all_ws_1 <-
146
+ readInWebCDI(all_data_ws1_path) %>%
147
+ select( #drop a bunch of columns that were screwing up the merge with prolific data
148
+ -opt_out,
149
+ -country,
150
+ -sibling_boolean,
151
+ -sibling_data,
152
+ -sibling_count,
153
+ -caregiver_other
154
+ )
155
+ all_ws_2 <-
156
+ readInWebCDI(all_data_ws2_path) %>%
157
+ select( #drop a bunch of columns that were screwing up the merge with prolific data
158
+ -opt_out,
159
+ -country,
160
+ -sibling_boolean,
161
+ -sibling_data,
162
+ -sibling_count,
163
+ -caregiver_other
164
+ )
165
+ all_ws_raw <-
166
+ all_ws_1 %>%
167
+ bind_rows(all_ws_2) %>%
168
+ mutate(completed = case_when(
169
+ stringr::str_to_lower(completed) == "true" ~ TRUE,
170
+ stringr::str_to_lower(completed) == "false" ~ FALSE
171
+ ))
172
+ all_wg_raw <- readInWebCDI(all_data_wg_path)
173
+ knitr::opts_chunk$set(echo = TRUE)
174
+ library(tidyverse)
175
+ library(png)
176
+ library(knitr)
177
+ library(markdown)
178
+ library(lmerTest)
179
+ library(ggthemes)
180
+ library(psych)
181
+ library(magrittr)
182
+ library(tidyboot)
183
+ library(fs)
184
+ library(ggmap)
185
+ library(lubridate)
186
+ source(path(here::here(), "file_paths.R"))
187
+ source(functions_script)
188
+ #Variables to tinker with
189
+ min_completion_time = 8.5
190
+ all_ws_1 <-
191
+ readInWebCDI(all_data_ws1_path) %>%
192
+ select( #drop a bunch of columns that were screwing up the merge with prolific data
193
+ -opt_out,
194
+ -country,
195
+ -sibling_boolean,
196
+ -sibling_data,
197
+ -sibling_count,
198
+ -caregiver_other
199
+ )
200
+ all_ws_2 <-
201
+ readInWebCDI(all_data_ws2_path) %>%
202
+ select( #drop a bunch of columns that were screwing up the merge with prolific data
203
+ -opt_out,
204
+ -country,
205
+ -sibling_boolean,
206
+ -sibling_data,
207
+ -sibling_count,
208
+ -caregiver_other
209
+ )
210
+ all_ws_raw <-
211
+ all_ws_1 %>%
212
+ bind_rows(all_ws_2) %>%
213
+ mutate(completed = case_when(
214
+ stringr::str_to_lower(completed) == "true" ~ TRUE,
215
+ stringr::str_to_lower(completed) == "false" ~ FALSE
216
+ ))
217
+ all_wg_raw <- readInWebCDI(all_data_wg_path)
218
+ View(all_wg_raw)
219
+ #WG
220
+ wg_filtered <-
221
+ all_wg_raw %>%
222
+ filterIllnesses() %>%
223
+ filterBirthweight() %>%
224
+ filterMultilingual() %>%
225
+ filterVision() %>%
226
+ filterHearing() %>%
227
+ getEthnicities() %>%
228
+ getMaternalEd() %>%
229
+ getCompletionInterval() %>%
230
+ filter(completedBackgroundInfo == "TRUE") %>% #get rid of kids with demos
231
+ filter_age_wg()
232
+ ws_filtered <-
233
+ all_ws_raw %>%
234
+ filterIllnesses() %>%
235
+ filterBirthweight() %>%
236
+ filterMultilingual() %>%
237
+ filterVision() %>%
238
+ filterHearing() %>%
239
+ getEthnicities() %>%
240
+ getMaternalEd() %>%
241
+ getCompletionInterval() %>%
242
+ filter(completedBackgroundInfo == "TRUE") %>%
243
+ filter_age_ws()
244
+ #Comprehension and production measures
245
+ ws_filtered %>%
246
+ filter(`Total Produced` < 688 & !is.na(maternal_ed)) %>%
247
+ ggplot(aes(age, `Total Produced`, color = maternal_ed)) +
248
+ ggthemes::theme_few() +
249
+ geom_jitter(alpha = 0.3, width = 0.225) +
250
+ coord_cartesian(ylim = c(0, 686)) +
251
+ geom_smooth(method = "lm") +
252
+ labs(
253
+ x = "Age in months",
254
+ y = "Total words produced",
255
+ color = "Maternal education"
256
+ )
257
+ wg_filtered %>%
258
+ filter(!is.na(maternal_ed)) %>%
259
+ ggplot(aes(age, `Words Understood`, color = maternal_ed)) +
260
+ ggthemes::theme_few() +
261
+ geom_jitter(alpha = 0.3, width = 0.225) +
262
+ geom_smooth(method = "lm") +
263
+ coord_cartesian(ylim = c(0, 390)) +
264
+ labs(
265
+ x = "Age in months",
266
+ y = "Total words understood",
267
+ color = "Maternal education"
268
+ )
269
+ #Demographic analyses on the entire sample
270
+ demographics_df <-
271
+ bind_rows(
272
+ wg_filtered %>%
273
+ select(
274
+ study_name,
275
+ subject_id,
276
+ age,
277
+ ethnicity,
278
+ maternal_ed,
279
+ words_produced = `Words Produced`
280
+ ),
281
+ ws_filtered %>%
282
+ select(
283
+ study_name,
284
+ subject_id,
285
+ age,
286
+ ethnicity,
287
+ maternal_ed,
288
+ words_produced = `Total Produced`
289
+ )
290
+ )
291
+ ethnicity_plot_df <-
292
+ demographics_df %>%
293
+ getEthnicitySummary() %>%
294
+ filter(!is.na(ethnicity)) %>%
295
+ mutate(`Current study` = prop.table(n)) %>%
296
+ left_join(old_ethnicity_numbers, by = "ethnicity") %>%
297
+ select(-n) %>%
298
+ pivot_longer(
299
+ cols = c(`Current study`, `2007 manual`),
300
+ names_to = "study",
301
+ values_to = "proportion"
302
+ )
303
+ ethnicity_plot <-
304
+ ethnicity_plot_df %>%
305
+ ggplot(aes(ethnicity, proportion, fill = study)) +
306
+ geom_col(position = "dodge") +
307
+ labs(
308
+ y = "Proportion of\nrespondents"
309
+ ) +
310
+ theme_few() +
311
+ theme(
312
+ legend.title = element_blank(),
313
+ axis.text = element_text(size = 14),
314
+ axis.title = element_text(size = 13),
315
+ legend.text = element_text(size = 13),
316
+ axis.title.x = element_blank(),
317
+ plot.title = element_text(size = 15),
318
+ plot.caption = element_text(hjust = 0)
319
+ )
320
+ ethnicity_plot
321
+ #Maternal ed analysis on the full sample
322
+ maternal_ed_plot_df <-
323
+ demographics_df %>%
324
+ count(maternal_ed) %>%
325
+ mutate(`Current study` = prop.table(n)) %>%
326
+ left_join(old_momed_numbers, by = "maternal_ed") %>%
327
+ select(-n) %>%
328
+ pivot_longer(
329
+ cols = c(`Current study`, `2007 manual`),
330
+ names_to = "study",
331
+ values_to = "proportion"
332
+ ) %>%
333
+ mutate(
334
+ maternal_ed = fct_relevel(
335
+ maternal_ed,
336
+ "Some high school or less",
337
+ "High school diploma",
338
+ "Some college education",
339
+ "College diploma or more"
340
+ )
341
+ ) %>%
342
+ filter(!is.na(maternal_ed))
343
+ x_axis_labs <- c(
344
+ "Some high school\n or less",
345
+ "High school\ndiploma",
346
+ "Some college\neducation",
347
+ "College diploma\nor more"
348
+ )
349
+ maternal_ed_plot <-
350
+ maternal_ed_plot_df %>%
351
+ ggplot(aes(maternal_ed, proportion, fill = study)) +
352
+ geom_col(position = "dodge") +
353
+ theme_few() +
354
+ theme(
355
+ legend.title = element_blank(),
356
+ axis.text.x = element_text(angle = 30, vjust = 0.9, hjust = 1, size = 13.5),
357
+ axis.title.x = element_blank(),
358
+ legend.text = element_text(size = 13),
359
+ plot.caption = element_text(hjust = 0)
360
+ ) +
361
+ scale_x_discrete(labels = x_axis_labs)
362
+ maternal_ed_plot
363
+ View(getEthnicitySummary)
364
+ if(!"devtools" %in% rownames(installed.packages())) install.packages("devtools")
365
+ devtools::install_github("crsh/papaja")
366
+ devtools::install_github("crsh/papaja")
367
+ devtools::install_github("crsh/papaja")
368
+ devtools::install_github("crsh/papaja")
369
+ remove.packages("digest")
370
+ devtools::install_github("crsh/papaja")
371
+ devtools::install_github("crsh/papaja")
372
+ devtools::install_github("crsh/papaja")
373
+ install.packages("digest")
374
+ devtools::install_github("crsh/papaja")
375
+ remove.packages("tiblle")
376
+ devtools::install_github("crsh/papaja")
377
+ devtools::install_github("crsh/papaja")
378
+ install.packages("rlang")
379
+ install.packages("rlang")
380
+ devtools::install_github("crsh/papaja")
381
+ install.packages("backport")
382
+ devtools::install_github("crsh/papaja")
383
+ install.packages("backports")
384
+ devtools::install_github("crsh/papaja")
0 commit comments