I'm trying to use the gt package in R to make a summary table. My data are structured as:
Value Condition_1 Condition_2 Type
0.33 LN 0.5 <10%
0.43 LN 0.5 <20%
0.23 LN 0.5 >20%
0.43 LN 0.6 <10%
0.23 LN 0.6 <20%
0.33 LN 0.6 >20%
0.33 LS 0.5 <10%
0.43 LS 0.5 <20%
0.23 LS 0.5 >20%
0.43 LS 0.6 <10%
0.23 LS 0.6 <20%
0.33 LS 0.6 >20%
I'd like the resulting table to look like:
Type <10% <20% >20%
LN-0.5
0.33 0.43 0.23
LN-0.6
0.43 0.23 0.33
LS-0.5
0.33 0.43 0.23
LS-0.6
0.43 0.23 0.33
I'm getting pretty close I think, and currently have my code set up as:
df %>% gt(rowname_col = c("value"),
groupname_col = c("Condition_1", "Condition_2")) %>%
summary_rows(groups = TRUE,
columns = vars(value),
fns = list(avg = ~mean(.)))
I thought it would be as simple as swapping
columns = vars(value) for columns = vars(Type) but that option can only handle numeric vectors (as far as I can tell). Can anyone please help figure this out? Thanks in advance!
