-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_02-02_academics.qmd
More file actions
executable file
·313 lines (278 loc) · 7.57 KB
/
_02-02_academics.qmd
File metadata and controls
executable file
·313 lines (278 loc) · 7.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
## Academic Skills {#sec-academics}
{{< include _02-02_academics_text.qmd >}}
```{r}
#| label: setup-academics
#| include: false
# domain
domains <- c("Academic Skills")
# Target phenotype
pheno <- "academics"
# Read the CSV file into a data frame
academics <- vroom::vroom("neurocog.csv")
```
```{r}
#| label: export-academics
#| include: false
#| eval: true
# Filter the data frame to keep only rows where 'domain' equals 'domains'
academics <-
academics |>
dplyr::filter(domain %in% domains)
# Select specific columns from the data frame
academics <- academics |>
dplyr::select(
test,
test_name,
scale,
raw_score,
# age_equiv,
score,
ci_95,
percentile,
range,
domain,
subdomain,
narrow,
pass,
verbal,
timed,
result,
z,
z_mean_domain,
z_sd_domain,
z_mean_subdomain,
z_sd_subdomain,
z_mean_narrow,
z_sd_narrow,
z_mean_pass,
z_sd_pass,
z_mean_verbal,
z_sd_verbal,
z_mean_timed,
z_sd_timed
)
# Write the resulting data frame to a new CSV file
# The file name is created by concatenating the 'pheno' variable and ".csv"
# NA values are replaced with an empty string in the output file
# Column names are included in the output file
# If the file already exists, it is overwritten (not appended)
readr::write_excel_csv(academics, here::here("data", paste0(pheno, ".csv")), na = "", col_names = TRUE, append = FALSE)
```
```{r}
#| label: data-academics
#| include: false
#| eval: true
# Read the data using the read_data function from the bwu library
# The phenotype is specified by the 'pheno' variable
data <- academics
scales <- c(
"Academic Fluency Composite",
"Academic Language Readiness Index",
"Academic Skills Battery (ASB) Composite",
"Alphabet Writing Fluency",
"Associational Fluency",
"Basic Reading",
"Comprehension Composite",
"Decoding Composite",
"Decoding Fluency",
"Decoding",
"Dyslexia Index",
"Essay Composition",
"Expression Composite",
"Expressive Vocabulary",
"Letter & Word Recognition",
"Letter Naming Facility",
"Listening Comprehension",
"Math Composite",
"Math Computation",
"Math Concepts & Applications",
"Math Fluency-Addition",
"Math Fluency-Multiplication",
"Math Fluency-Subtraction",
"Math Fluency",
"Math Problem Solving",
"Mathematics",
"Nonsense Word Decoding",
"Numerical Operations",
"Object Naming Facility",
"Oral Discourse Comprehension",
"Oral Expression",
"Oral Fluency Composite",
"Oral Language Composite",
"Oral Reading Fluency",
"Oral Word Fluency",
"Orthographic Choice",
"Orthographic Fluency",
"Orthographic Processing Composite",
"Orthographic Processing Extended",
"Orthographic Processing",
"Phonemic Proficiency",
"Phonological Processing",
"Pseudoword Decoding",
"Reading Composite",
"Reading Comprehension",
"Reading Comprehension",
"Reading Fluency Composite",
"Reading Fluency",
"Reading Index",
"Reading Understanding Composite",
"Reading Vocabulary",
"Reading",
"Receptive Vocabulary",
"Sentence Composition",
"Sentence Comprehension",
"Sentence Repetition",
"Sentence Writing Fluency",
"Silent Reading Fluency",
"Sound-Symbol Composite",
"Spelling",
"Total Achievement",
"Word Reading",
"Word Recognition Fluency",
"Writing Fluency",
"Written Expression",
"Written Language Composite"
)
# Filter the data using the filter_data function from the bwu library
# The domain is specified by the 'domains' variable
# The scale is specified by the 'scales' variable
data_academics <- bwu::filter_data(data, domain = domains, scale = scales)
```
```{r}
#| label: text-academics
#| cache: true
#| include: false
# export text
bwu::cat_neuropsych_results(data = data_academics, file = "_02-02_academics_text.qmd")
```
```{r}
#| label: qtbl-academics
#| dev: tikz
#| fig-process: pdf2png
#| include: false
# Set the default engine for tikz to "xetex"
options(tikzDefaultEngine = "xetex")
# arguments
table_name <- "table_academics"
vertical_padding <- 0
multiline <- TRUE
# footnotes
fn_standard_score <- gt::md("Standard score: Mean = 100 [50th‰], SD ± 15 [16th‰, 84th‰]")
# Define the groups for the table
grp_academics <- list(
standard_score = c("KTEA-3", "WIAT-4", "WRAT-5")
)
# Create the table using the tbl_gt function from the bwu library
# source("table_gt.R")
bwu::tbl_gt(
data = data_academics,
pheno = pheno,
table_name = table_name,
fn_standard_score = fn_standard_score,
grp_standard_score = grp_academics[["standard_score"]],
dynamic_grp = grp_academics,
vertical_padding = vertical_padding,
multiline = multiline
)
```
```{r}
#| label: fig-academics-subdomain
#| include: false
#| fig-height: 6
#| out-height: 100%
#| fig-cap: "_Reading ability_ consists of three interrelated abilities: decoding, comprehension, and fluency. _Writing ability_ can be described in terms of spelling, grammar, expression of ideas, and writing fluency. _Math ability_ can be described in terms of calculation skills, applied problem solving, and math fluency."
# data_academics <- data_academics |>
# dplyr::filter(
# scale == "School Readiness Composite (SRC)"
# )
# Arguments
filename <- "fig_academics_subdomain.svg"
colors <- NULL
# Define the x and y variables for the dotplot
x <- data_academics$z_mean_subdomain
y <- data_academics$subdomain
# Make dotplot
bwu::dotplot(
data = data_academics,
x = x,
y = y,
colors = colors,
return_plot = TRUE,
filename = filename,
na.rm = TRUE
)
```
```{r}
#| label: fig-academics-narrow
#| include: false
#| fig-height: 6
#| out-height: 100%
#| fig-cap: "_Reading ability_ consists of three interrelated abilities: decoding, comprehension, and fluency. _Writing ability_ can be described in terms of spelling, grammar, expression of ideas, and writing fluency. _Math ability_ can be described in terms of calculation skills, applied problem solving, and math fluency."
# Define the filename for the plot
filename <- "fig_academics_narrow.svg"
# Define the x and y variables for the dotplot
x <- data_academics$z_mean_narrow
y <- data_academics$narrow
# plot args
colors <- NULL
# Make dotplot
bwu::dotplot(
data = data_academics,
x = x,
y = y,
colors = colors,
return_plot = TRUE,
filename = filename,
na.rm = TRUE
)
```
```{=typst}
#let domain(title: none, file_qtbl, file_fig) = {
let font = (font: "Roboto Slab", size: 0.7em)
set text(..font)
pad(top: 0.5em)[]
grid(
columns: (50%, 50%),
gutter: 8pt,
figure(
[#image(file_qtbl)],
caption: figure.caption(position: top, [#title]),
kind: "qtbl",
supplement: [*Table*],
),
figure(
[#image(file_fig, width: auto)],
caption: figure.caption(
position: bottom,
[
Reading, writing, and math are the three main academic skills assessed on exam. _Reading ability_ consists of three interrelated abilities: decoding, comprehension, and fluency. _Writing ability_ can be described in terms of spelling, grammar, expression of ideas, and writing fluency. _Math ability_ can be described in terms of calculation skills, applied problem solving, and math fluency.
],
),
placement: none,
kind: "image",
supplement: [*Figure*],
gap: 0.5em,
),
)
}
```
```{=typst}
#let title = "Academic Skills"
#let file_qtbl = "table_academics.png"
#let file_fig = "fig_academics_subdomain.svg"
#domain(
title: [#title Scores],
file_qtbl,
file_fig,
)
```
```{=typst}
#let title = "Academic Skills"
#let file_qtbl = "table_academics.png"
#let file_fig = "fig_academics_narrow.svg"
#domain(
title: [#title Scores],
file_qtbl,
file_fig,
)
```