-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_02-11_adaptive.qmd
215 lines (188 loc) · 5.28 KB
/
_02-11_adaptive.qmd
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
## Adaptive (#sec-adaptive)
{{< include _02-11_adaptive_text.qmd >}}
```{r}
#| label: setup-adaptive
#| include: false
domains <- c("Adaptive Functioning")
pheno <- "adaptive"
```
```{r}
#| label: export-adaptive
#| include: false
# Read the CSV file into a data frame
adaptive <- vroom::vroom("neurobehav.csv")
# Filter the data frame based on certain conditions
# Keep only the rows where 'domain' equals 'domains' and 'z_mean_domain' is not NA
adaptive <- adaptive |>
dplyr::filter(domain %in% domains)
# Select specific columns from the data frame
adaptive <- adaptive |>
dplyr::select(
test,
test_name,
scale,
raw_score,
score,
ci_95,
percentile,
range,
domain,
subdomain,
narrow,
pass,
verbal,
timed,
description,
result,
z,
z_mean_domain,
z_sd_domain,
z_mean_subdomain,
z_sd_subdomain,
z_mean_narrow,
z_sd_narrow
)
# Write the 'adaptive' data frame to a CSV file
# The file name is derived from the 'pheno' variable
readr::write_excel_csv(adaptive, paste0(pheno, ".csv"), na = "", col_names = TRUE, append = FALSE)
```
```{r}
#| label: data-adaptive
#| include: false
# Read and filter the data
data <- adaptive
# Define the scales of interest
scales <- c(
"General Adaptive Composite (GAC)",
"Conceptual",
"Communication",
"Functional Pre-Academics",
"Self-Direction",
"Adaptive Skills Index",
"Leisure",
"Social Index",
"Social",
"Adaptive",
"Practical",
"Community Use",
"School Living",
"Home Living",
"Health and Safety",
"Self-Care",
"Motor",
"General Adaptive Composite",
"Conceptual Skills Index",
"Functional Academics",
"Practical Skills Index",
"Work"
)
# 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_adaptive <- bwu::filter_data(data, domain = domains, scale = scales)
```
```{r}
#| label: text-adaptive
#| cache: true
#| include: false
# Generate the text for the adaptive domain
bwu::cat_neuropsych_results(data = data_adaptive, file = "_02-11_adaptive_text.qmd")
```
```{r}
#| label: qtbl-adaptive
#| dev: tikz
#| fig-process: pdf2png
#| include: false
# Set the default engine for tikz to "xetex"
options(tikzDefaultEngine = "xetex")
# Define the table name, vertical padding, and multiline setting
table_name <- "table_adaptive"
vertical_padding <- 0
multiline <- TRUE
# Define the source note
fn_scaled_score <- gt::md("Scaled score: Mean = 10 [50th‰], SD ± 3 [16th‰, 84th‰]")
fn_standard_score <- gt::md("Index score: Mean = 100 [50th‰], SD ± 15 [16th‰, 84th‰]")
# Define the groups for the table
grp_adaptive <- list(
standard_score = c(
"ABAS-3 Parent", "ABAS-3", "ABAS-3 Teacher"
),
scaled_score = c(
"ABAS-3 Parent", "ABAS-3", "ABAS-3 Teacher"
)
)
# Create the table using the tbl_gt function from the bwu library
bwu::tbl_gt(
data = data_adaptive,
pheno = pheno,
table_name = table_name,
vertical_padding = vertical_padding,
fn_standard_score = fn_standard_score,
fn_scaled_score = fn_scaled_score,
grp_standard_score = grp_adaptive[["standard_score"]],
grp_scaled_score = grp_adaptive[["scaled_score"]],
dynamic_grp = grp_adaptive,
multiline = multiline
)
```
```{r}
#| label: fig-adaptive
#| include: false
#| fig-cap: "Adaptive functioning is a broad term that refers to the collection of conceptual, social, and practical skills that enable individuals to function independently and meet the demands of everyday life. These skills include things like communication, self-care, home living, social skills, and community use."
# Dotplot args
colors <- NULL
return_plot <- TRUE
filename <- "fig_adaptive.svg"
# vars to plot
x <- data_adaptive$z_mean_narrow
y <- data_adaptive$narrow
# Suppress warnings from being converted to errors
options(warn = 1) # Set warn to 1 to make warnings not halt execution
# Create the dotplot using the dotplot function from the bwu library
bwu::dotplot(
data = data_adaptive,
x = x,
y = y,
colors = colors,
return_plot = return_plot,
filename = filename,
na.rm = TRUE
)
# Reset warning options to default if needed
options(warn = 0) # Reset to default behavior
```
```{=typst}
#let domain(title: none, file_qtbl, file_fig) = {
let font = (font: "Roboto Slab", size: 0.5em)
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)],
caption: figure.caption(position: bottom, [
Adaptive functioning is a broad term that refers to the collection of conceptual, social, and practical skills that enable individuals to function independently and meet the demands of everyday life. These skills include things like communication, self-care, home living, social skills, and community use.
]),
placement: none,
kind: "image",
supplement: [Figure],
gap: 0.5em,
),
)
}
```
```{=typst}
#let title = "Adaptive Functioning"
#let file_qtbl = "table_adaptive.png"
#let file_fig = "fig_adaptive.svg"
#domain(
title: [#title Scores],
file_qtbl,
file_fig
)
```