Created
November 16, 2020 22:15
-
-
Save kylebutts/0f411737220c30ca64a3eddbec2ead6f to your computer and use it in GitHub Desktop.
summary_table_body.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
df <- mtcars %>% | |
group_by(cyl) %>% | |
summarize(mean_mpg = mean(mpg), sd_mpg = sd(mpg)) %>% | |
mutate( | |
mpg_tex = paste0(format(round(mean_mpg, 2), nsmall = 2), " (", format(round(sd_mpg, 2), nsmall = 2), ")"), | |
tex = paste(cyl, mpg_tex, sep = " & ") | |
) | |
cat(df$tex, sep = " \\\\ \n") | |
#> 4 & 26.66 (4.51) \\ | |
#> 6 & 19.74 (1.45) \\ | |
#> 8 & 15.10 (2.56) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment