Description Usage Arguments Details Value See Also Examples
Append two datasets' rows in a pairwise fashion. In other words, append the 1st row of the first dataset with the 1st row of the second dataset, the 2nd row of the first with the 2nd row of the second, and so on.
1 | pairbind(x, y), pairbind_df(x, y)
|
x |
2D object (e.g. Data frame, matrix) |
y |
Same as above. |
This function can be useful for kable-friendly frequency distribution tables.
Same as above; except in the case of pairbind_df, which outputs a data frame.
https://github.com/robertschnitman/afp, lapply
, do.call
, rbind
, https://purrr.tidyverse.org/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | library(tidyverse)
library(knitr)
freq_df <- with(diamonds, table(color, clarity)) %>%
as.data.frame() %>%
spread(NCOL(.) - 1, NCOL(.)) %>%
mutate(Total = apply(.[, 2:NCOL(.)], 1, sum))
prop_df <- freq_df
prop_df[, 2:NCOL(prop_df)] <- prop_df[, 2:NCOL(prop_df)]/prop_df$Total
prop_df[, 2:NCOL(prop_df)] %<>%
map_df(~ paste0(round(.x*100), '%'))
freq_df %<>%
format(., big.mark = ',', scientific = FALSE) %>%
map_df(as.character)
prop_df %<>% map_df(as.character)
pairbind_df(freq_df, prop_df) %>% kable()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.