Thats a good step, you can improve how you share code, by formatting it for the forum, by using a three backticks, to open and close code formatting segments.
```
like this
```
I ran the following based on what you provided
dat <- structure(list(cognitive_status = structure(c(
2L, 2L, 1L, 2L,
1L, 1L, 2L, 1L, 2L, 2L
), .Label = c(
"No cognitive impairment",
"MCI"
), label = "Cognitive status group", class = c(
"labelled",
"factor"
)), dt_alph_gs = structure(c(
0.516795865633075, 0.225903614457831,
0.575815738963532, 0.409976084728391, 0.471883602044829, 0.430416068866571,
NA, 0.556070435588508, 0.614439324116744, 0.316122233930453
), label = "DT alphabet time mean", class = c(
"labelled",
"numeric"
))), row.names = c(NA, -10L), class = "data.frame")
library(tidyverse)
dat %>%
group_by(cognitive_status) %>%
summarize(medn = median(dt_alph_gs, na.rm = T))
This did not give an error, but a result
# A tibble: 2 x 2
cognitive_status medn
<fct> <dbl>
1 No cognitive impairment 0.514
2 MCI 0.410
when you run what I run, do you get this same result, or an error ?