# NOT RUN {
library(tidyr)
# Use `exibble` to create a gt table;
# format the `num` column as numeric
# with three decimal places and with no
# use of digit separators
tab_1 <-
exibble %>%
gt() %>%
fmt_number(
columns = vars(num),
decimals = 3,
use_seps = FALSE
)
# Use `countrypops` to create a gt
# table; format all numeric columns
# to use large-number suffixing
tab_2 <-
countrypops %>%
dplyr::select(country_code_3, year, population) %>%
dplyr::filter(
country_code_3 %in% c(
"CHN", "IND", "USA", "PAK", "IDN")
) %>%
dplyr::filter(year > 1975 & year %% 5 == 0) %>%
tidyr::spread(year, population) %>%
dplyr::arrange(desc(`2015`)) %>%
gt(rowname_col = "country_code_3") %>%
fmt_number(
columns = 2:9,
decimals = 2,
suffixing = TRUE
)
# }
Run the code above in your browser using DataLab