Repository navigation
|
I am trying to make a table with multiple rowname columns and I keep getting warnings. Here's an example, what would be the correct way to do this? library(gt)
library(dplyr)
# this works without warning
gtcars |>
select(mfr, model, hp) |>
gt() |>
grand_summary_rows(columns = hp, fns = "mean")
# warning messages and mean value in wrong place
gtcars |>
select(mfr, model, hp) |>
gt(rowname_col = c("mfr", "model")) |>
grand_summary_rows(columns = hp, fns = "mean")These are the warnings I get: Warning messages:
1: In mapply(SIMPLIFY = FALSE, USE.NAMES = FALSE, summary_df[j, ], :
longer argument not a multiple of length of shorter
2: In mapply(SIMPLIFY = FALSE, USE.NAMES = FALSE, summary_df[j, ], :
longer argument not a multiple of length of shorter
3: In mapply(SIMPLIFY = FALSE, USE.NAMES = FALSE, summary_df[j, ], :
longer argument not a multiple of length of shorter
4: In mapply(SIMPLIFY = FALSE, USE.NAMES = FALSE, summary_df[j, ], :
longer argument not a multiple of length of shorter |
Answered by
xanzplug
Aug 11, 2026
Replies: 1 comment
|
The issue is that |
0 replies
Answer selected by
jslatane
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The issue is that
rowname_colonly accepts a single column name, so passingc("mfr", "model")causes the warnings and puts the summary value in the wrong place. You'd need to either combinemfrandmodelinto one column and use that asrowname_col, or keep both as regular columns.gtdoesn't support multiple rowname columns throughrowname_col.