diff --git a/.gitignore b/.gitignore index ae86318757..bb8552d8b6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,27 +1,38 @@ -inst/doc # History files .Rhistory .Rapp.history +# Docs folder from `pkgdown::build_site()` +docs/ +inst/doc + # Session Data files .RData + # Example code in package build process *-Ex.R + # Output files from R CMD build /*.tar.gz + # Output files from R CMD check /*.Rcheck/ + # RStudio files .Rproj.user/ + # produced vignettes vignettes/*.html vignettes/*.pdf + # knitr and R markdown default cache directories /*_cache/ /cache/ + # Temporary files created by R markdown *.utf8.md *.knit.md .Rproj.user + # Other files .DS_Store diff --git a/.travis.yml b/.travis.yml index 4c14b3f7f9..332fb7bb81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,4 +43,4 @@ jobs: on: all_branches: true github-token: - secure: "VYVhr8KRgfJp5cexTVEciYvlULcCj8z6Qe63UUNw2Ob81vii9e9J450R+gS80qO8TYxwhrzkby21CESHwGbXIn6J9skW/V0CDlIHb/GGmwSKLUnbRT5X0On89Zogqz+yiY6HUa4oRZUSdFqo4pLjq56UHy/PK/GvAkDCA4tOKLc7qm9nwXov3NZJssgCo24beYq2FxXb2ifEfJ06/oB5E2/aR1E6HktR0KvbLspGP7DboRl/rbTg0wxpNAyUu49ZbRlC4I7Zl2tzehlq6MIO3u+0yVe7hyCwcrWBZbBLsekJ1tRlEs1Wh+O2q2NMSNFRmA8e3awQo7GO+maQRl2PFsO9Mn7P2oVRwaJzHkz+QKRtyJB8oNjwEJQDo2M0jW3ggEhQyO039tDic1b3iYi8QORBSwCkn6TbFlFedNdlnBhXskk7fSH4GEkr7Fq6//xKFRvEKZuLCKIbrCOnQxuDI6Ak7OWe1A1cXlOqDcvuLBg5ZFMvXMh3RrE4z4AoGyPr2xY3lOM1hoHDtjLBAAAJ7IpH251qAahsCxBLhWufHQ6xmz020aV8mg89KVsU58SbVBKwjyFRoR+1IaTb/dsxtWItW5AMh5kwwH36PQp2L7eixBBFUAyJaEpoNEGTJg24B5QJPMDfu1MXEkSBisrwtuKYzRuJ/XJd77Z47BkukEc=" + secure: "GrujWLlpdgy59mI5ZiYnlT8p1LDpqoms/ROeBuFOhJ6tZa6lNYzG4tR2iGkJS5a9hykMbkDootmx95ktC/ovjvFrWXLb8Ql+XiWri1cb17G3SzcEz7m35RA6fKNsu9BVM1qhydBnSS6UtFGWkK/+4dqkT3/3b7XnO2WmF8MtFno9iPnBRybgIYjt5qrBNUZQPcvkjL6FV1x2X2O5lwrH4ND7ueM6wgs5BtxCQxhaBcu9gmDbjlnPsfCbqQvxVNuifguF9AzDPE97nylDyr9jeycehWkvHioFKjYhK/yWfANuXGOgYb0I+vCyxDfxIrOfc+IhUEGaSxqZ3H3fy3Mdc8Bd2+IhC6KbdpSJiB57N1OPIHj6I8a9YlELZN2EczDXUxfvppTlDYBAWUpfI2uPoBMskBTgPXP838u+jNrAcMERkNAIgb4VOPVnf+MbGei2gfSWXmFvH+z0EjwpPxhv0nP1+5TT2RsErwpEyrA8qO14uICx+/gKPZulMKeZApjWYtOyJRjeRYPFUwrLx8S52CeR1el5QyiuPke9oTxmg9gMuoVWGReoDvtOIaz6LbgUPy9/o+gHNPb70DLYii9h2thzJtMTr30jnpGsosIaBghpregaOvxEIyo5xJGRBn9z0R1n6VnRWjyIC/VTh0ljn1pvC26LVrQj7DKa8SMP6Jw=" diff --git a/R/datasets.R b/R/datasets.R index df3bb9c993..3b73aa03d2 100644 --- a/R/datasets.R +++ b/R/datasets.R @@ -179,7 +179,7 @@ #' \item \code{southw_ckn}: The Southwest Chicken Pizza (Chicken, Tomatoes, Red #' Peppers, Red Onions, Jalapeno Peppers, Corn, Cilantro, Chipotle Sauce) #' \item \code{cali_ckn}: The California Chicken Pizza (Chicken, Artichoke, -#' Spinach, Garlic, JalapeƱo Peppers, Fontina Cheese, Gouda Cheese) +#' Spinach, Garlic, Jalapeno Peppers, Fontina Cheese, Gouda Cheese) #' \item \code{ckn_pesto}: The Chicken Pesto Pizza (Chicken, Tomatoes, Red #' Peppers, Spinach, Garlic, Pesto Sauce) #' \item \code{ckn_alfredo}: The Chicken Alfredo Pizza (Chicken, Red Onions, diff --git a/R/format_data.R b/R/format_data.R index 4fac619875..1d6b566b36 100644 --- a/R/format_data.R +++ b/R/format_data.R @@ -142,37 +142,84 @@ fmt_number <- function(data, locale = NULL) { # Use locale-based marks if a locale ID is provided - if (!is.null(locale) && locale %in% locales$base_locale_id) { - sep_mark <- get_locale_sep_mark(locale = locale) - dec_mark <- get_locale_dec_mark(locale = locale) - } else if (!is.null(locale) && !(locale %in% locales$base_locale_id)) { - stop("The supplied `locale` is not available in the list of supported locales.", - call. = FALSE) - } + sep_mark <- get_locale_sep_mark(locale, sep_mark, use_seps) + dec_mark <- get_locale_dec_mark(locale, dec_mark) - # Provide an empty string for `sep_mark` if we choose - # to not use digit group separators - if (!use_seps) { - sep_mark <- "" - } + # Normalize the `suffixing` input to either return a character vector + # of suffix labels, or NULL (the case where `suffixing` is FALSE) + suffix_labels <- normalize_suffixing_inputs(suffixing, scale_by) - # Normalize the `suffixing` input to either return a - # character vector of suffix labels, or NULL (the - # case where `suffixing` is FALSE) - suffix_labels <- normalize_suffixing_inputs(suffixing) + # Create a function factory for the `fmt_number()` function + fmt_number_factory <- function(context = "html") { - # If choosing to perform large-number suffixing - # of numeric values, force `scale_by` to be 1.0 - if (!is.null(suffix_labels)) { + function(x) { - if (!missing(scale_by) && !identical(scale_by, 1.0)) { - warning("The value for `scale_by` can't be changed if `suffixing` is ", - "anything other than `FALSE`. The value provided to `scale_by` ", - "will be ignored.", - call. = FALSE) - } + # Define the marks by context + minus_mark <- context_minus_mark(context) + parens_marks <- context_parens_marks_number(context) + + # Determine which of `x` are not NA + non_na_x <- !is.na(x) + + # Create a possibly shorter vector of non-NA `x` values + x_vals <- x[non_na_x] + + # Create a tibble with scaled values for `x[non_na_x]` + # and the suffix labels to use for character formatting + suffix_df <- + num_suffix( + round(x_vals, decimals), + suffixes = suffix_labels, + scale_by = scale_by + ) + + # Scale the `x_vals` by the `scale_by` value + x_vals <- scale_x_values(x_vals, scale_by = suffix_df$scale_by) + + # Format all non-NA x values + x_str_vals <- + format_num_to_str( + x_vals, decimals, sep_mark, dec_mark, drop_trailing_zeros + ) + + # Paste vector of suffixes to the right of the `x_str_vals` + x_str_vals <- paste_right(x_str_vals, suffix_df$suffix) + + # Perform negative value formatting + if (any(x_vals < 0)) { + + # Handle replacement of the minus mark + x_str_vals <- + x_str_vals %>% + tidy_gsub("-", minus_mark, fixed = TRUE) + + # Handle case where negative values are to be placed within parentheses + if (negative_val == "parens") { + + # Selectively remove minus sign and paste between parentheses + x_str_vals[x_vals < 0] <- + paste_between( + x = gsub(paste0("^", minus_mark), "", x_str_vals[x_vals < 0]), + x_2 = parens_marks + ) + } + } + + # If in a LaTeX context, remove any double negative + # signs in the exponent + if (context == "latex") { + x_str_vals <- to_latex_math_mode(x_str_vals) + } + + # Handle formatting of pattern + x_str_vals <- apply_pattern_fmt_x(pattern, x_str_vals) - scale_by <- 1.0 + # Create `x_str` with the same length as `x`; place the + # `x_str_vals` into `str` (at the non-NA indices) + x_str <- rep(NA_character_, length(x)) + x_str[non_na_x] <- x_str_vals + x_str + } } # Capture expression in `rows` and `columns` @@ -181,79 +228,23 @@ fmt_number <- function(data, # Pass `data`, `columns`, `rows`, and the formatting # functions as a function list to `fmt()` - fmt(data = data, - columns = !!columns, - rows = !!rows, - fns = list( - default = function(x) { - - # Determine which of `x` are not NA - non_na_x <- !is.na(x) - - # Create a tibble with scaled values for - # `x[non_na_x]` and the suffix labels to - # use for character formatting - suffix_df <- - num_suffix( - x = round(x[non_na_x], decimals), - suffixes = suffix_labels - ) - - # If choosing to perform large-number suffixing - # of numeric values, replace `scale_by` with - # a vector of scaling values (of equal length - # with `x[non_na_x]`) - if (!is.null(suffix_labels)) { - scale_by <- suffix_df$scale_by[non_na_x] - } - - # Create `x_str` with same length as `x` - x_str <- rep(NA_character_, length(x)) - - # Format all non-NA x values - x_str[non_na_x] <- - formatC( - x = x[non_na_x] * scale_by, - digits = decimals, - mode = "double", - big.mark = sep_mark, - decimal.mark = dec_mark, - format = "f", - drop0trailing = drop_trailing_zeros) - - # Apply large-number suffixes to scaled and - # formatted values if that option is taken - if (!is.null(suffix_labels)) { - - # Apply vector of suffixes - x_str[non_na_x] <- - paste0(x_str[non_na_x], suffix_df$suffix[non_na_x]) - } - - # Handle negative values - if (negative_val == "parens") { - - # Determine which of `x` are not NA and also negative - negative_x <- x < 0 & !is.na(x) - - # Apply parentheses to the formatted value and remove - # the minus sign - x_str[negative_x] <- paste0("(", gsub("^-", "", x_str[negative_x]), ")") - } - - # Handle formatting of pattern - pre_post_txt <- get_pre_post_txt(pattern) - x_str[non_na_x] <- paste0(pre_post_txt[1], x_str[non_na_x], pre_post_txt[2]) - x_str - } - )) + fmt( + data = data, + columns = !!columns, + rows = !!rows, + fns = list( + html = fmt_number_factory(context = "html"), + latex = fmt_number_factory(context = "latex"), + default = fmt_number_factory(context = "default") + ) + ) } #' Format values to scientific notation #' -#' With numeric values in a \pkg{gt} table, we can perform formatting so that -#' the targeted values are presented in scientific notation. We can exert finer -#' finer control on the formatting with the following options: +#' With numeric values in a \pkg{gt} table, we can perform formatting so that the +#' targeted values are rendered in scientific notation. Furthermore, there is +#' fine control with the following options: #' \itemize{ #' \item decimals: choice of the number of decimal places, option to drop #' trailing zeros, and a choice of the decimal symbol @@ -312,89 +303,82 @@ fmt_scientific <- function(data, locale = NULL) { # Use locale-based marks if a locale ID is provided - if (!is.null(locale) && locale %in% locales$base_locale_id) { - sep_mark <- get_locale_sep_mark(locale = locale) - dec_mark <- get_locale_dec_mark(locale = locale) - } else if (!is.null(locale) && !(locale %in% locales$base_locale_id)) { - stop("The supplied `locale` is not available in the list of supported locales.", - call. = FALSE) - } + sep_mark <- get_locale_sep_mark(locale, sep_mark, use_seps = TRUE) + dec_mark <- get_locale_dec_mark(locale, dec_mark) - format_fcn_sci_notn_factory <- function(exp_start_str, exp_end_str) { + # Create a function factory for the `fmt_scientific()` function + fmt_scientific_factory <- function(context = "html") { function(x) { + # Define the marks by context + minus_mark <- context_minus_mark(context) + exp_marks <- context_exp_marks(context) + # Determine which of `x` are not NA non_na_x <- !is.na(x) - # Determine which of `x` don't require scientific notation - small_pos <- - ((x >= 1 & x < 10) | - (x <= -1 & x > -10) | - x == 0) & !is.na(x) + # Create a possibly shorter vector of non-NA `x` values + x_vals <- x[non_na_x] - # Create `x_str` with same length as `x` - x_str <- rep(NA_character_, length(x)) + # Scale the `x_vals` by the `scale_by` value + x_vals <- scale_x_values(x_vals, scale_by) + + # Determine which of `x` don't require the (x 10^n) + # since their order would be zero + small_pos <- has_order_zero(x_vals) - # Format the number component as a character vector - x_str[non_na_x] <- - formatC( - x = x[non_na_x] * scale_by, - digits = decimals, - mode = "double", - big.mark = sep_mark, - decimal.mark = dec_mark, - format = "e", - drop0trailing = drop_trailing_zeros) + # Format all non-NA x values + x_str_vals <- + format_num_to_str_e( + x_vals, decimals, sep_mark, dec_mark, + drop_trailing_zeros + ) # For any numbers that shouldn't have an exponent, remove # that portion from the character version if (any(small_pos)) { - x_str[small_pos] <- - split_scientific_notn(x_str[small_pos])$num + + x_str_vals[small_pos] <- + split_scientific_notn(x_str_vals[small_pos])$num } # For any non-NA numbers that do have an exponent, format # those according to the output context if (any(!small_pos)) { - sci_parts <- split_scientific_notn(x_str[non_na_x & !small_pos]) + sci_parts <- split_scientific_notn(x_str_vals[!small_pos]) - x_str[non_na_x & !small_pos] <- + x_str_vals[!small_pos] <- paste0( - sci_parts$num, exp_start_str, - sci_parts$exp, exp_end_str + sci_parts$num, exp_marks[1], + sci_parts$exp, exp_marks[2] ) } + # Handle replacement of the minus mark in number + # and exponent parts + x_str_vals <- + x_str_vals %>% + tidy_gsub("-", minus_mark, fixed = TRUE) + + # If in a LaTeX context, put formatted numbers + # in math mode + if (context == "latex") { + x_str_vals <- to_latex_math_mode(x_str_vals) + } + # Handle formatting of pattern - pre_post_txt <- get_pre_post_txt(pattern) - x_str[non_na_x] <- paste0(pre_post_txt[1], x_str[non_na_x], pre_post_txt[2]) + x_str_vals <- apply_pattern_fmt_x(pattern, x_str_vals) + + # Create `x_str` with the same length as `x`; place the + # `x_str_vals` into `str` (at the non-NA indices) + x_str <- rep(NA_character_, length(x)) + x_str[non_na_x] <- x_str_vals x_str } } - # Create the default formatting function for scientific notation - format_fcn_sci_notn_default <- - format_fcn_sci_notn_factory( - exp_start_str = " x 10(", - exp_end_str = ")" - ) - - # Create the HTML formatting function for scientific notation - format_fcn_sci_notn_html <- - format_fcn_sci_notn_factory( - exp_start_str = " × 10", - exp_end_str = "" - ) - - # Create the LaTeX formatting function for scientific notation - format_fcn_sci_notn_latex <- - format_fcn_sci_notn_factory( - exp_start_str = "$ \\times 10^{", - exp_end_str = "}$" - ) - # Capture expression in `rows` and `columns` rows <- rlang::enquo(rows) columns <- rlang::enquo(columns) @@ -406,9 +390,10 @@ fmt_scientific <- function(data, columns = !!columns, rows = !!rows, fns = list( - html = format_fcn_sci_notn_html, - default = format_fcn_sci_notn_default, - latex = format_fcn_sci_notn_latex) + html = fmt_scientific_factory(context = "html"), + latex = fmt_scientific_factory(context = "latex"), + default = fmt_scientific_factory(context = "default") + ) ) } @@ -484,135 +469,103 @@ fmt_percent <- function(data, locale = NULL) { # Use locale-based marks if a locale ID is provided - if (!is.null(locale) && locale %in% locales$base_locale_id) { - sep_mark <- get_locale_sep_mark(locale = locale) - dec_mark <- get_locale_dec_mark(locale = locale) - } else if (!is.null(locale) && !(locale %in% locales$base_locale_id)) { - stop("The supplied `locale` is not available in the list of supported locales.", - call. = FALSE) - } - - # Provide an empty string for `sep_mark` if we choose - # to not use digit group separators - if (!use_seps) { - sep_mark <- "" - } - - # Capture expression in `rows` and `columns` - rows <- rlang::enquo(rows) - columns <- rlang::enquo(columns) - - # Pass `data`, `columns`, `rows`, and the formatting - # functions as a function list to `fmt()` - fmt(data = data, - columns = !!columns, - rows = !!rows, - fns = list( - latex = function(x) { - - # Determine which of `x` are not NA - non_na_x <- !is.na(x) - - # Create `x_str` with same length as `x` - x_str <- rep(NA_character_, length(x)) - - # Format all non-NA x values - x_str[non_na_x] <- - formatC( - x = x[non_na_x] * 100.0, - digits = decimals, - mode = "double", - big.mark = sep_mark, - decimal.mark = dec_mark, - format = "f", - drop0trailing = drop_trailing_zeros) - - if (placement == "right") { - - x_str[non_na_x] <- - paste0( - x_str[non_na_x], - ifelse(incl_space, " \\%", "\\%") - ) - - } else { - - x_str[non_na_x] <- - paste0( - ifelse(incl_space, "\\% ", "\\%"), - x_str[non_na_x] - ) - } + sep_mark <- get_locale_sep_mark(locale, sep_mark, use_seps) + dec_mark <- get_locale_dec_mark(locale, dec_mark) - # Handle negative values - if (negative_val == "parens") { + # Create a function factory for the `fmt_percent()` function + fmt_percent_factory <- function(context = "html") { - # Determine which of `x` are not NA and also negative - negative_x <- x < 0 & !is.na(x) - - # Apply parentheses to the formatted value and remove - # the minus sign - x_str[negative_x] <- paste0("(", gsub("^-", "", x_str[negative_x]), ")") - } + function(x) { - # Handle formatting of pattern - pre_post_txt <- get_pre_post_txt(pattern) - x_str[non_na_x] <- paste0(pre_post_txt[1], x_str[non_na_x], pre_post_txt[2]) - x_str - }, - default = function(x) { + # Define the marks by context + minus_mark <- context_minus_mark(context) + percent_mark <- context_percent_mark(context) + parens_marks <- context_parens_marks(context) - # Determine which of `x` are not NA - non_na_x <- !is.na(x) + # Determine which of `x` are not NA + non_na_x <- !is.na(x) - # Create `x_str` with same length as `x` - x_str <- rep(NA_character_, length(x)) + # Create a possibly shorter vector of non-NA `x` values + x_vals <- x[non_na_x] + + # Scale the `x_vals` by the `scale_by` value + x_vals <- scale_x_values(x_vals, scale_by = 100) + + # Format all non-NA x values + x_str_vals <- + format_num_to_str( + x_vals, decimals, sep_mark, dec_mark, drop_trailing_zeros + ) + + # Handle placement of the percent symbol + x_str_vals <- + x_str_vals %>% + paste_on_side( + x_side = ifelse(incl_space, " ", ""), + direction = placement + ) %>% + paste_on_side( + x_side = percent_mark, + direction = placement + ) %>% + swap_adjacent_text_groups( + pattern_1 = percent_mark, + pattern_2 = "-" + ) + + # Perform negative value formatting + if (any(x_vals < 0)) { + + # Handle replacement of the minus mark + x_str_vals <- + x_str_vals %>% + tidy_gsub("-", minus_mark, fixed = TRUE) + + # Handle case where negative values are to be placed within parentheses + if (negative_val == "parens") { + + # Selectively remove minus sign and paste between parentheses + x_str_vals[x_vals < 0] <- + paste_between( + x = gsub(paste0("^", minus_mark), "", x_str_vals[x_vals < 0]), + x_2 = parens_marks + ) + } + } - # Format all non-NA x values - x_str[non_na_x] <- - formatC( - x = x[non_na_x] * 100.0, - digits = decimals, - mode = "double", - big.mark = sep_mark, - decimal.mark = dec_mark, - format = "f", - drop0trailing = drop_trailing_zeros) - - if (placement == "right") { - - x_str[non_na_x] <- - paste0( - x_str[non_na_x], - ifelse(incl_space, " %", "%") - ) - - } else { - - x_str[non_na_x] <- - paste0( - ifelse(incl_space, "% ", "%"), - x_str[non_na_x] - ) - } + # If in a LaTeX context, remove any double negative + # signs in the exponent + if (context == "latex") { + x_str_vals <- to_latex_math_mode(x_str_vals) + } - # Handle negative values - if (negative_val == "parens") { + # Handle formatting of pattern + x_str_vals <- apply_pattern_fmt_x(pattern, x_str_vals) - # Determine which of `x` are not NA and also negative - negative_x <- x < 0 & !is.na(x) + # Create `x_str` with the same length as `x`; place the + # `x_str_vals` into `str` (at the non-NA indices) + x_str <- rep(NA_character_, length(x)) + x_str[non_na_x] <- x_str_vals + x_str + } + } - # Apply parentheses to the formatted value and remove - # the minus sign - x_str[negative_x] <- paste0("(", gsub("^-", "", x_str[negative_x]), ")") - } + # Capture expression in `rows` and `columns` + rows <- rlang::enquo(rows) + columns <- rlang::enquo(columns) - # Handle formatting of pattern - pre_post_txt <- get_pre_post_txt(pattern) - x_str[non_na_x] <- paste0(pre_post_txt[1], x_str[non_na_x], pre_post_txt[2]) - x_str - } - )) + # Pass `data`, `columns`, `rows`, and the formatting + # functions as a function list to `fmt()` + fmt( + data = data, + columns = !!columns, + rows = !!rows, + fns = list( + html = fmt_percent_factory(context = "html"), + latex = fmt_percent_factory(context = "latex"), + default = fmt_percent_factory(context = "default") + ) + ) } #' Format values as currencies @@ -726,63 +679,100 @@ fmt_currency <- function(data, locale = NULL) { # Use locale-based marks if a locale ID is provided - if (!is.null(locale) && locale %in% locales$base_locale_id) { - sep_mark <- get_locale_sep_mark(locale = locale) - dec_mark <- get_locale_dec_mark(locale = locale) - } else if (!is.null(locale) && !(locale %in% locales$base_locale_id)) { - stop("The supplied `locale` is not available in the list of supported locales.", - call. = FALSE) - } + sep_mark <- get_locale_sep_mark(locale, sep_mark, use_seps) + dec_mark <- get_locale_dec_mark(locale, dec_mark) # Stop function if `currency` does not have a valid value - if (!is_currency_valid(currency)) { - stop("The supplied `currency` is not available in the list of supported currencies.", - call. = FALSE) - } + validate_currency(currency) - # Get the currency string for the HTML context - currency_str_html <- get_currency_str(currency) + # Get the number of decimal places + decimals <- get_currency_decimals(currency, decimals, use_subunits) - # Get the currency string for the non-HTML context - currency_str <- get_currency_str(currency, fallback_to_code = TRUE) + # Normalize the `suffixing` input to either return a character vector + # of suffix labels, or NULL (the case where `suffixing` is FALSE) + suffix_labels <- normalize_suffixing_inputs(suffixing, scale_by) - # Get the number of decimal places - if (is.null(decimals) & use_subunits) { + # Create a function factory for the `fmt_currency()` function + fmt_currency_factory <- function(context = "html") { - # Get decimal places using `get_currency_exponent()` fcn - if (currency %in% currency_symbols$curr_symbol) { - decimals <- 2 - } else { - decimals <- get_currency_exponent(currency = currency) - } + function(x) { - } else if (is.null(decimals) & use_subunits == FALSE) { - decimals <- 0 - } + # Define the marks by context + negative_currency_mark <- context_negative_currency_mark(context) + currency_str <- context_currency_str(context, currency) + currency_str_regex <- context_currency_str_regex(context) + parens_marks <- context_parens_marks(context) - # Provide an empty string for `sep_mark` if we choose - # to not use digit group separators - if (!use_seps) { - sep_mark <- "" - } + # Determine which of `x` are not NA + non_na_x <- !is.na(x) + + # Create a possibly shorter vector of non-NA `x` values + x_vals <- x[non_na_x] + + # Create a tibble with scaled values for `x[non_na_x]` + # and the suffix labels to use for character formatting + suffix_df <- + num_suffix( + round(x_vals, decimals), + suffixes = suffix_labels, + scale_by = scale_by + ) + + # Scale the `x_vals` by the `scale_by` value + x_vals <- scale_x_values(x_vals, scale_by = suffix_df$scale_by) + + # Format all non-NA x values + x_str_vals <- format_num_to_str_c(x_vals, decimals, sep_mark, dec_mark) + + # Paste vector of suffixes to the right of the `x_str_vals` + x_str_vals <- paste_right(x_str_vals, suffix_df$suffix) + + # Handle placement of the currency symbol + x_str_vals <- + x_str_vals %>% + paste_currency_str(currency_str, incl_space, placement) + + # Perform negative value formatting + if (any(x_vals < 0)) { + + # Handle replacement of the minus mark + x_str_vals <- + x_str_vals %>% + tidy_gsub("-", negative_currency_mark, fixed = TRUE) + + # Handle case where negative values are to be placed within parentheses + if (negative_val == "parens") { + + # Selectively remove minus sign and paste between parentheses + x_str_vals[x_vals < 0] <- + paste_between( + x = x_str_vals[x_vals < 0] %>% + tidy_gsub( + negative_currency_mark, "", + fixed = TRUE + ), + x_2 = parens_marks + ) + } + } - # Normalize the `suffixing` input to either return a - # character vector of suffix labels, or NULL (the - # case where `suffixing` is FALSE) - suffix_labels <- normalize_suffixing_inputs(suffixing) + # If in a LaTeX context, wrap values in math mode + if (context == "latex") { - # If choosing to perform large-number suffixing - # of numeric values, force `scale_by` to be 1.0 - if (!is.null(suffix_labels)) { + x_str_vals <- + x_str_vals %>% + to_latex_math_mode() + } - if (!missing(scale_by) && !identical(scale_by, 1.0)) { - warning("The value for `scale_by` can't be changed if `suffixing` is ", - "anything other than `FALSE`. The value provided to `scale_by` ", - "will be ignored.", - call. = FALSE) - } + # Handle formatting of pattern + x_str_vals <- apply_pattern_fmt_x(pattern, x_str_vals) - scale_by <- 1.0 + # Create `x_str` with the same length as `x`; place the + # `x_str_vals` into `str` (at the non-NA indices) + x_str <- rep(NA_character_, length(x)) + x_str[non_na_x] <- x_str_vals + x_str + } } # Capture expression in `rows` and `columns` @@ -791,248 +781,16 @@ fmt_currency <- function(data, # Pass `data`, `columns`, `rows`, and the formatting # functions as a function list to `fmt()` - fmt(data = data, - columns = !!columns, - rows = !!rows, - fns = list( - default = function(x) { - - # Determine which of `x` are not NA - non_na_x <- !is.na(x) - - # Determine which of `x` are not NA and also negative - negative_x <- x < 0 & !is.na(x) - - # Create `x_str` with same length as `x` - x_str <- rep(NA_character_, length(x)) - - # Create a tibble with scaled values for - # `x[non_na_x]` and the suffix labels to - # use for character formatting - suffix_df <- - num_suffix( - x = round(x[non_na_x], decimals), - suffixes = suffix_labels - ) - - # If choosing to perform large-number suffixing - # of numeric values, replace `scale_by` with - # a vector of scaling values (of equal length - # with `x[non_na_x]`) - if (!is.null(suffix_labels)) { - scale_by <- suffix_df$scale_by[non_na_x] - } - - # Format all non-NA x values - x_str[non_na_x] <- - formatC( - x = x[non_na_x] * scale_by, - digits = decimals, - mode = "double", - big.mark = sep_mark, - decimal.mark = dec_mark, - format = "f", - drop0trailing = FALSE) - - # Apply large-number suffixes to scaled and - # formatted values if that option is taken - if (!is.null(suffix_labels)) { - - # Apply vector of suffixes - x_str[non_na_x] <- - paste0(x_str[non_na_x], suffix_df$suffix[non_na_x]) - } - - # Handle placement of the currency symbol - if (placement == "left") { - - x_str[non_na_x] <- - paste0( - currency_str, - ifelse(incl_space, " ", ""), x_str[non_na_x] - ) - - } else { - - x_str[non_na_x] <- - paste0( - x_str[non_na_x], - ifelse(incl_space, " ", ""), currency_str - ) - } - - # Handle negative values - if (negative_val == "parens") { - - # Apply parentheses to the formatted value and remove - # the minus sign - x_str[negative_x] <- paste0("(", gsub("-", "", x_str[negative_x]), ")") - } - - # Handle formatting of pattern - pre_post_txt <- get_pre_post_txt(pattern) - x_str[non_na_x] <- paste0(pre_post_txt[1], x_str[non_na_x], pre_post_txt[2]) - x_str - }, - html = function(x) { - - # Determine which of `x` are not NA - non_na_x <- !is.na(x) - - # Determine which of `x` are not NA and also negative - negative_x <- x < 0 & !is.na(x) - - # Create `x_str` with same length as `x` - x_str <- rep(NA_character_, length(x)) - - # Create a tibble with scaled values for - # `x[non_na_x]` and the suffix labels to - # use for character formatting - suffix_df <- - num_suffix( - x = round(x[non_na_x], decimals), - suffixes = suffix_labels - ) - - # If choosing to perform large-number suffixing - # of numeric values, replace `scale_by` with - # a vector of scaling values (of equal length - # with `x[non_na_x]`) - if (!is.null(suffix_labels)) { - scale_by <- suffix_df$scale_by[non_na_x] - } - - # Format all non-NA x values - x_str[non_na_x] <- - formatC( - x = x[non_na_x] * scale_by, - digits = decimals, - mode = "double", - big.mark = sep_mark, - decimal.mark = dec_mark, - format = "f", - drop0trailing = FALSE) - - # Apply large-number suffixes to scaled and - # formatted values if that option is taken - if (!is.null(suffix_labels)) { - - # Apply vector of suffixes - x_str[non_na_x] <- - paste0(x_str[non_na_x], suffix_df$suffix[non_na_x]) - } - - # Handle placement of the currency symbol - if (placement == "left") { - - x_str[non_na_x] <- - paste0( - currency_str_html, - ifelse(incl_space, " ", ""), x_str[non_na_x] - ) - - } else { - - x_str[non_na_x] <- - paste0( - x_str[non_na_x], - ifelse(incl_space, " ", ""), currency_str_html - ) - } - - # Handle negative values - if (negative_val == "parens") { - - # Apply parentheses to the formatted value and remove - # the minus sign - x_str[negative_x] <- paste0("(", gsub("-", "", x_str[negative_x]), ")") - } - - # Handle formatting of pattern - pre_post_txt <- get_pre_post_txt(pattern) - x_str[non_na_x] <- paste0(pre_post_txt[1], x_str[non_na_x], pre_post_txt[2]) - x_str - }, - latex = function(x) { - - # Determine which of `x` are not NA - non_na_x <- !is.na(x) - - # Determine which of `x` are not NA and also negative - negative_x <- x < 0 & !is.na(x) - - # Create `x_str` with same length as `x` - x_str <- rep(NA_character_, length(x)) - - # Create a tibble with scaled values for - # `x[non_na_x]` and the suffix labels to - # use for character formatting - suffix_df <- - num_suffix( - x = round(x[non_na_x], decimals), - suffixes = suffix_labels - ) - - # If choosing to perform large-number suffixing - # of numeric values, replace `scale_by` with - # a vector of scaling values (of equal length - # with `x[non_na_x]`) - if (!is.null(suffix_labels)) { - scale_by <- suffix_df$scale_by[non_na_x] - } - - # Format all non-NA x values - x_str[non_na_x] <- - formatC( - x = x[non_na_x] * scale_by, - digits = decimals, - mode = "double", - big.mark = sep_mark, - decimal.mark = dec_mark, - format = "f", - drop0trailing = FALSE) - - # Apply large-number suffixes to scaled and - # formatted values if that option is taken - if (!is.null(suffix_labels)) { - - # Apply vector of suffixes - x_str[non_na_x] <- - paste0(x_str[non_na_x], suffix_df$suffix[non_na_x]) - } - - # Handle placement of the currency symbol - if (placement == "left") { - - x_str[non_na_x] <- - paste0( - markdown_to_latex(currency_str), - ifelse(incl_space, " ", ""), x_str[non_na_x] - ) - - } else { - - x_str[non_na_x] <- - paste0( - x_str[non_na_x], ifelse(incl_space, " ", ""), - markdown_to_latex(currency_str) - ) - } - - # Handle negative values - if (negative_val == "parens") { - - # Apply parentheses to the formatted value and remove - # the minus sign - x_str[negative_x] <- paste0("(", gsub("-", "", x_str[negative_x]), ")") - } - - # Handle formatting of pattern - pre_post_txt <- get_pre_post_txt(pattern) - x_str[non_na_x] <- paste0(pre_post_txt[1], x_str[non_na_x], pre_post_txt[2]) - x_str - } - )) + fmt( + data = data, + columns = !!columns, + rows = !!rows, + fns = list( + html = fmt_currency_factory(context = "html"), + latex = fmt_currency_factory(context = "latex"), + default = fmt_currency_factory(context = "default") + ) + ) } #' Format values as dates @@ -1549,9 +1307,13 @@ fmt_passthrough <- function(data, # Create `x_str` with same length as `x` x_str <- rep(NA_character_, length(x)) + # TODO: Deal with NA values in x # Handle formatting of pattern - pre_post_txt <- get_pre_post_txt(pattern) - x_str <- paste0(pre_post_txt[1], x, pre_post_txt[2]) + x_str <- + apply_pattern_fmt_x( + pattern, + values = x + ) if (escape) { x_str <- x_str %>% process_text(context = "html") @@ -1564,9 +1326,13 @@ fmt_passthrough <- function(data, # Create `x_str` with same length as `x` x_str <- rep(NA_character_, length(x)) + # TODO: Deal with NA values in x # Handle formatting of pattern - pre_post_txt <- get_pre_post_txt(pattern) - x_str <- paste0(pre_post_txt[1], x, pre_post_txt[2]) + x_str <- + apply_pattern_fmt_x( + pattern, + values = x + ) if (escape) { x_str <- x_str %>% process_text(context = "latex") @@ -1579,9 +1345,13 @@ fmt_passthrough <- function(data, # Create `x_str` with same length as `x` x_str <- rep(NA_character_, length(x)) + # TODO: Deal with NA values in x # Handle formatting of pattern - pre_post_txt <- get_pre_post_txt(pattern) - x_str <- paste0(pre_post_txt[1], x, pre_post_txt[2]) + x_str <- + apply_pattern_fmt_x( + pattern, + values = x + ) x_str } diff --git a/R/gt_options_default.R b/R/gt_options_default.R index 511267ecfc..71e8afef66 100644 --- a/R/gt_options_default.R +++ b/R/gt_options_default.R @@ -17,24 +17,24 @@ gt_options_default <- function() { "column_labels_background_color", TRUE, "columns", NA_character_, "column_labels_font_size", TRUE, "columns", "16px", "column_labels_font_weight", TRUE, "columns", "initial", - "stub_group_background_color", TRUE, "stub_group", NA_character_, - "stub_group_font_size", TRUE, "stub_group", "16px", - "stub_group_font_weight", TRUE, "stub_group", "initial", - "stub_group_border_top_style", TRUE, "stub_group", "solid", - "stub_group_border_top_width", TRUE, "stub_group", "2px", - "stub_group_border_top_color", TRUE, "stub_group", "#A8A8A8", - "stub_group_border_bottom_style", TRUE, "stub_group", "solid", - "stub_group_border_bottom_width", TRUE, "stub_group", "2px", - "stub_group_border_bottom_color", TRUE, "stub_group", "#A8A8A8", - "field_border_top_style", TRUE, "field", "solid", - "field_border_top_width", TRUE, "field", "2px", - "field_border_top_color", TRUE, "field", "#A8A8A8", - "field_border_bottom_style", TRUE, "field", "solid", - "field_border_bottom_width", TRUE, "field", "2px", - "field_border_bottom_color", TRUE, "field", "#A8A8A8", + "row_group_background_color", TRUE, "row_group", NA_character_, + "row_group_font_size", TRUE, "row_group", "16px", + "row_group_font_weight", TRUE, "row_group", "initial", + "row_group_border_top_style", TRUE, "row_group", "solid", + "row_group_border_top_width", TRUE, "row_group", "2px", + "row_group_border_top_color", TRUE, "row_group", "#A8A8A8", + "row_group_border_bottom_style", TRUE, "row_group", "solid", + "row_group_border_bottom_width", TRUE, "row_group", "2px", + "row_group_border_bottom_color", TRUE, "row_group", "#A8A8A8", + "table_body_border_top_style", TRUE, "table_body", "solid", + "table_body_border_top_width", TRUE, "table_body", "2px", + "table_body_border_top_color", TRUE, "table_body", "#A8A8A8", + "table_body_border_bottom_style", TRUE, "table_body", "solid", + "table_body_border_bottom_width", TRUE, "table_body", "2px", + "table_body_border_bottom_color", TRUE, "table_body", "#A8A8A8", "row_padding", TRUE, "row", "8px", "row_striping_include_stub", TRUE, "row", "TRUE", - "row_striping_include_field", TRUE, "row", "TRUE", + "row_striping_include_table_body", TRUE, "row", "TRUE", "summary_row_background_color", TRUE, "summary_row", NA_character_, "summary_row_padding", TRUE, "summary_row", "8px", "summary_row_text_transform", TRUE, "summary_row", "inherit", diff --git a/R/helpers.R b/R/helpers.R index d39bd6c3a8..b6fbfbf271 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -26,10 +26,10 @@ #' \item \code{cells_stub()}: targets row labels in the table stub using the #' \code{rows} argument. #' -#' \item \code{cells_data()}: targets data cells in the table field using +#' \item \code{cells_data()}: targets data cells in the table body using #' intersections of \code{columns} and \code{rows}. #' -#' \item \code{cells_summary()}: targets summary cells in the table field using +#' \item \code{cells_summary()}: targets summary cells in the table body using #' the \code{groups} argument and intersections of \code{columns} and #' \code{rows}. #' } diff --git a/R/info_tables.R b/R/info_tables.R index 500d23bb10..853bd2d487 100644 --- a/R/info_tables.R +++ b/R/info_tables.R @@ -450,9 +450,11 @@ info_paletteer <- function(color_pkgs = NULL) { locations = cells_data(columns = vars(length)) ) %>% tab_options( - stub_group.background.color = "#FFFFF0", + row_group.background.color = "#FFFFF0", column_labels.background.color = "#666660", - stub_group.font.weight = "600", stub_group.font.size = "smaller") %>% + row_group.font.weight = "600", + row_group.font.size = "smaller" + ) %>% tab_source_note(source_note = md( paste("The **paletteer** package is maintained by Emil Hvitfeldt. More information can be", "found on [the **paletteer** site](https://emilhvitfeldt.github.io/paletteer/) and", diff --git a/R/tab_options.R b/R/tab_options.R index 4e82501849..831af5a676 100644 --- a/R/tab_options.R +++ b/R/tab_options.R @@ -9,38 +9,38 @@ #' given in units of pixels. The \code{\link{px}()} and \code{\link{pct}()} #' helper functions can also be used to pass in numeric values and obtain #' values as pixel or percent units. -#' @param table.font.size,heading.title.font.size,heading.subtitle.font.size,column_labels.font.size,stub_group.font.size,footnote.font.size,sourcenote.font.size +#' @param table.font.size,heading.title.font.size,heading.subtitle.font.size,column_labels.font.size,row_group.font.size,footnote.font.size,sourcenote.font.size #' font sizes for the parent text element \code{table} and the following child #' elements: \code{heading.title}, \code{heading.subtitle}, \code{columns}, -#' \code{stub_group}, \code{footnote}, and \code{sourcenote}. Can be specified -#' as a single-length character vector with units of pixels -#' (e.g., \code{12px}) or as a percentage (e.g., \code{80\%}). If provided as a +#' \code{row_group}, \code{footnote}, and \code{sourcenote}. Can be specified +#' as a single-length character vector with units of pixels (e.g., +#' \code{12px}) or as a percentage (e.g., \code{80\%}). If provided as a #' single-length numeric vector, it is assumed that the value is given in #' units of pixels. The \code{\link{px}()} and \code{\link{pct}()} helper #' functions can also be used to pass in numeric values and obtain values as #' pixel or percent units. -#' @param column_labels.font.weight,stub_group.font.weight the font weight of -#' the \code{columns} and \code{stub_group} text element. +#' @param column_labels.font.weight,row_group.font.weight the font weight of +#' the \code{columns} and \code{row_group} text element. #' @param summary_row.text_transform,grand_summary_row.text_transform an option #' to apply text transformations to the label text in each summary row. -#' @param table.background.color,heading.background.color,column_labels.background.color,stub_group.background.color,summary_row.background.color,grand_summary_row.background.color +#' @param table.background.color,heading.background.color,column_labels.background.color,row_group.background.color,summary_row.background.color,grand_summary_row.background.color #' background colors for the parent element \code{table} and the following -#' child elements: \code{heading}, \code{columns}, \code{stub_group}, -#' \code{summary_row}, and \code{field}. A color name or a hexadecimal color -#' code should be provided. +#' child elements: \code{heading}, \code{columns}, \code{row_group}, +#' \code{summary_row}, and \code{table_body}. A color name or a hexadecimal +#' color code should be provided. #' @param table.border.top.style,table.border.top.width,table.border.top.color #' the style, width, and color of the table's top border. #' @param heading.border.bottom.style,heading.border.bottom.width,heading.border.bottom.color #' the style, width, and color of the heading's bottom border. -#' @param stub_group.border.top.style,stub_group.border.top.width,stub_group.border.top.color -#' the style, width, and color of the stub heading's top border. -#' @param stub_group.border.bottom.style,stub_group.border.bottom.width,stub_group.border.bottom.color -#' the style, width, and color of the stub heading's bottom border. -#' @param field.border.top.style,field.border.top.width,field.border.top.color -#' the style, width, and color of the field's top border. -#' @param field.border.bottom.style,field.border.bottom.width,field.border.bottom.color -#' the style, width, and color of the field's bottom border. -#' @param row.padding,summary_row.padding,grand_summary_row.padding the amount +#' @param row_group.border.top.style,row_group.border.top.width,row_group.border.top.color +#' the style, width, and color of the row group's top border. +#' @param row_group.border.bottom.style,row_group.border.bottom.width,row_group.border.bottom.color +#' the style, width, and color of the row group's bottom border. +#' @param table_body.border.top.style,table_body.border.top.width,table_body.border.top.color +#' the style, width, and color of the table body's top border. +#' @param table_body.border.bottom.style,table_body.border.bottom.width,table_body.border.bottom.color +#' the style, width, and color of the table body's bottom border. +#' @param row.padding,summary_row.padding,grand_summary_row.padding the amount #' of padding in each row and in each type of summary row. #' @param footnote.sep the separating characters between adjacent footnotes in #' the footnotes section. The default value produces a linebreak. @@ -56,8 +56,8 @@ #' the footnote and source note sections. #' @param row.striping.include_stub an option for whether to include the stub #' when striping rows. -#' @param row.striping.include_field an option for whether to include the field -#' when striping rows. +#' @param row.striping.include_table_body an option for whether to include the +#' table body when striping rows. #' @return an object of class \code{gt_tbl}. #' @examples #' # Use `exibble` to create a gt table with @@ -169,21 +169,21 @@ tab_options <- function(data, column_labels.background.color = NULL, column_labels.font.size = NULL, column_labels.font.weight = NULL, - stub_group.background.color = NULL, - stub_group.font.size = NULL, - stub_group.font.weight = NULL, - stub_group.border.top.style = NULL, - stub_group.border.top.width = NULL, - stub_group.border.top.color = NULL, - stub_group.border.bottom.style = NULL, - stub_group.border.bottom.width = NULL, - stub_group.border.bottom.color = NULL, - field.border.top.style = NULL, - field.border.top.width = NULL, - field.border.top.color = NULL, - field.border.bottom.style = NULL, - field.border.bottom.width = NULL, - field.border.bottom.color = NULL, + row_group.background.color = NULL, + row_group.font.size = NULL, + row_group.font.weight = NULL, + row_group.border.top.style = NULL, + row_group.border.top.width = NULL, + row_group.border.top.color = NULL, + row_group.border.bottom.style = NULL, + row_group.border.bottom.width = NULL, + row_group.border.bottom.color = NULL, + table_body.border.top.style = NULL, + table_body.border.top.width = NULL, + table_body.border.top.color = NULL, + table_body.border.bottom.style = NULL, + table_body.border.bottom.width = NULL, + table_body.border.bottom.color = NULL, row.padding = NULL, summary_row.background.color = NULL, summary_row.padding = NULL, @@ -198,7 +198,7 @@ tab_options <- function(data, sourcenote.font.size = NULL, sourcenote.padding = NULL, row.striping.include_stub = NULL, - row.striping.include_field = NULL) { + row.striping.include_table_body = NULL) { # Extract the `opts_df` data frame object from `data` opts_df <- attr(data, "opts_df", exact = TRUE) @@ -332,129 +332,129 @@ tab_options <- function(data, opts_df <- opts_df_set(opts_df, "column_labels_font_weight", column_labels.font.weight) } - # stub_group.background.color - if (!is.null(stub_group.background.color)) { + # row_group.background.color + if (!is.null(row_group.background.color)) { opts_df <- opts_df_set( - opts_df, "stub_group_background_color", stub_group.background.color) + opts_df, "row_group_background_color", row_group.background.color) } - # stub_group.font.size - if (!is.null(stub_group.font.size)) { + # row_group.font.size + if (!is.null(row_group.font.size)) { - if (is.numeric(stub_group.font.size)) { - stub_group.font.size <- paste0(stub_group.font.size, "px") + if (is.numeric(row_group.font.size)) { + row_group.font.size <- paste0(row_group.font.size, "px") } opts_df <- opts_df_set( - opts_df, "stub_group_font_size", stub_group.font.size) + opts_df, "row_group_font_size", row_group.font.size) } - # stub_group.font.weight - if (!is.null(stub_group.font.weight)) { + # row_group.font.weight + if (!is.null(row_group.font.weight)) { opts_df <- opts_df_set( - opts_df, "stub_group_font_weight", stub_group.font.weight) + opts_df, "row_group_font_weight", row_group.font.weight) } - # stub_group.border.top.style - if (!is.null(stub_group.border.top.style)) { + # row_group.border.top.style + if (!is.null(row_group.border.top.style)) { opts_df <- opts_df_set( - opts_df, "stub_group_border_top_style", stub_group.border.top.style) + opts_df, "row_group_border_top_style", row_group.border.top.style) } - # stub_group.border.top.width - if (!is.null(stub_group.border.top.width)) { + # row_group.border.top.width + if (!is.null(row_group.border.top.width)) { - if (is.numeric(stub_group.border.top.width)) { - stub_group.border.top.width <- paste0(stub_group.border.top.width, "px") + if (is.numeric(row_group.border.top.width)) { + row_group.border.top.width <- paste0(row_group.border.top.width, "px") } opts_df <- opts_df_set( - opts_df, "stub_group_border_top_width", stub_group.border.top.width) + opts_df, "row_group_border_top_width", row_group.border.top.width) } - # stub_group.border.top.color - if (!is.null(stub_group.border.top.color)) { + # row_group.border.top.color + if (!is.null(row_group.border.top.color)) { opts_df <- opts_df_set( - opts_df, "stub_group_border_top_color", stub_group.border.top.color) + opts_df, "row_group_border_top_color", row_group.border.top.color) } - # stub_group.border.bottom.style - if (!is.null(stub_group.border.bottom.style)) { + # row_group.border.bottom.style + if (!is.null(row_group.border.bottom.style)) { opts_df <- opts_df_set( - opts_df, "stub_group_border_bottom_style", stub_group.border.bottom.style) + opts_df, "row_group_border_bottom_style", row_group.border.bottom.style) } - # stub_group.border.bottom.width - if (!is.null(stub_group.border.bottom.width)) { + # row_group.border.bottom.width + if (!is.null(row_group.border.bottom.width)) { - if (is.numeric(stub_group.border.bottom.width)) { - stub_group.border.bottom.width <- paste0(stub_group.border.bottom.width, "px") + if (is.numeric(row_group.border.bottom.width)) { + row_group.border.bottom.width <- paste0(row_group.border.bottom.width, "px") } opts_df <- opts_df_set( - opts_df, "stub_group_border_bottom_width", stub_group.border.bottom.width) + opts_df, "row_group_border_bottom_width", row_group.border.bottom.width) } - # stub_group.border.bottom.color - if (!is.null(stub_group.border.bottom.color)) { + # row_group.border.bottom.color + if (!is.null(row_group.border.bottom.color)) { opts_df <- opts_df_set( - opts_df, "stub_group_border_bottom_color", stub_group.border.bottom.color) + opts_df, "row_group_border_bottom_color", row_group.border.bottom.color) } - # field.border.top.style - if (!is.null(field.border.top.style)) { + # table_body.border.top.style + if (!is.null(table_body.border.top.style)) { opts_df <- opts_df_set( - opts_df, "field_border_top_style", field.border.top.style) + opts_df, "table_body_border_top_style", table_body.border.top.style) } - # field.border.top.width - if (!is.null(field.border.top.width)) { + # table_body.border.top.width + if (!is.null(table_body.border.top.width)) { - if (is.numeric(field.border.top.width)) { - field.border.top.width <- paste0(field.border.top.width, "px") + if (is.numeric(table_body.border.top.width)) { + table_body.border.top.width <- paste0(table_body.border.top.width, "px") } opts_df <- opts_df_set( - opts_df, "field_border_top_width", field.border.top.width) + opts_df, "table_body_border_top_width", table_body.border.top.width) } - # field.border.top.color - if (!is.null(field.border.top.color)) { + # table_body.border.top.color + if (!is.null(table_body.border.top.color)) { opts_df <- opts_df_set( - opts_df, "field_border_top_color", field.border.top.color) + opts_df, "table_body_border_top_color", table_body.border.top.color) } - # field.border.bottom.style - if (!is.null(field.border.bottom.style)) { + # table_body.border.bottom.style + if (!is.null(table_body.border.bottom.style)) { opts_df <- opts_df_set( - opts_df, "field_border_bottom_style", field.border.bottom.style) + opts_df, "table_body_border_bottom_style", table_body.border.bottom.style) } - # field.border.bottom.width - if (!is.null(field.border.bottom.width)) { + # table_body.border.bottom.width + if (!is.null(table_body.border.bottom.width)) { - if (is.numeric(field.border.bottom.width)) { - field.border.bottom.width <- paste0(field.border.bottom.width, "px") + if (is.numeric(table_body.border.bottom.width)) { + table_body.border.bottom.width <- paste0(table_body.border.bottom.width, "px") } opts_df <- opts_df_set( - opts_df, "field_border_bottom_width", field.border.bottom.width) + opts_df, "table_body_border_bottom_width", table_body.border.bottom.width) } - # field.border.bottom.color - if (!is.null(field.border.bottom.color)) { + # table_body.border.bottom.color + if (!is.null(table_body.border.bottom.color)) { opts_df <- opts_df_set( - opts_df, "field_border_bottom_color", field.border.bottom.color) + opts_df, "table_body_border_bottom_color", table_body.border.bottom.color) } # row.padding @@ -577,11 +577,11 @@ tab_options <- function(data, opts_df, "row_striping_include_stub", row.striping.include_stub) } - # row.striping.include_field - if (!is.null(row.striping.include_field)) { + # row.striping.include_table_body + if (!is.null(row.striping.include_table_body)) { opts_df <- opts_df_set( - opts_df, "row_striping_include_field", row.striping.include_field) + opts_df, "row_striping_include_table_body", row.striping.include_table_body) } # Write the modified `opts_df` to the `data` attribute diff --git a/R/tab_style.R b/R/tab_style.R index 4e41c12fe8..9062b9dcd6 100644 --- a/R/tab_style.R +++ b/R/tab_style.R @@ -80,7 +80,6 @@ #' date <= "2015-12-15" #' ) %>% #' dplyr::select(-c(adj_close, volume)) %>% -#' dplyr::mutate(date = as.character(date)) %>% #' gt() %>% #' tab_style( #' style = cells_styles( diff --git a/R/utils.R b/R/utils.R index 09ad198fb8..8884a851cd 100644 --- a/R/utils.R +++ b/R/utils.R @@ -1,4 +1,5 @@ -# Create a tibble containing date formats +#' Create a tibble containing date formats +#' #' @importFrom dplyr tribble #' @noRd date_formats <- function() { @@ -21,7 +22,8 @@ date_formats <- function() { "14", "y.mn.day", "%y/%m/%d") } -# Create a tibble containing time formats +#' Create a tibble containing time formats +#' #' @importFrom dplyr tribble #' @noRd time_formats <- function() { @@ -35,7 +37,8 @@ time_formats <- function() { "5", "h_p", "%I %P") } -# Transform `date_style` to `date_format` +#' Transform a `date_style` to a `date_format` +#' #' @importFrom dplyr filter pull #' @noRd get_date_format <- function(date_style) { @@ -59,7 +62,8 @@ get_date_format <- function(date_style) { } } -# Transform `time_style` to `time_format` +#' Transform a `time_style` to a `time_format` +#' #' @importFrom dplyr filter pull #' @noRd get_time_format <- function(time_style) { @@ -83,18 +87,8 @@ get_time_format <- function(time_style) { } } -# Determine if a provided `currency` type is valid -#' @noRd -is_currency_valid <- function(currency) { - - ifelse( - as.character(currency) %in% currency_symbols$curr_symbol | - as.character(currency) %in% currencies$curr_code | - as.character(currency) %in% currencies$curr_number, - TRUE, FALSE) -} - -# Transform `currency` to currency string +#' Transform a `currency` code to a currency string +#' #' @importFrom dplyr filter pull #' @noRd get_currency_str <- function(currency, @@ -149,7 +143,8 @@ get_currency_str <- function(currency, } } -# Transform `currency` to a currency exponent +#' Get a currency exponent from a currency code +#' #' @importFrom dplyr filter pull #' @noRd get_currency_exponent <- function(currency) { @@ -179,39 +174,13 @@ get_currency_exponent <- function(currency) { } } -# Get the `sep_mark` value from a locale -#' @importFrom dplyr filter pull -#' @noRd -get_locale_sep_mark <- function(locale) { - - sep_mark <- - locales %>% - dplyr::filter(base_locale_id == locale) %>% - dplyr::pull(group_sep) - - sep_mark <- ifelse(sep_mark == "", " ", sep_mark) - - sep_mark -} - -# Get the `dec_mark` value from a locale -#' @importFrom dplyr filter pull -#' @noRd -get_locale_dec_mark <- function(locale) { - - dec_mark <- - locales %>% - dplyr::filter(base_locale_id == locale) %>% - dplyr::pull(dec_sep) - - dec_mark -} - -# This function processes input text based on the class; if incoming text has -# the class `from_markdown` (applied by the `md()` helper function), then the -# text will be sanitized and transformed to HTML from Markdown. If the incoming -# text has the class `html` (applied by `html()` helper function), then -# the text will be seen as HTML and it won't undergo sanitization +#' Process text based on rendering context any applied classes +#' +#' If the incoming text has the class `from_markdown` (applied by the `md()` +#' helper function), then the text will be sanitized and transformed to HTML +#' from Markdown. If the incoming text has the class `html` (applied by `html()` +#' helper function), then the text will be seen as HTML and it won't undergo +#' sanitization #' @importFrom stringr str_replace_all #' @importFrom htmltools htmlEscape #' @importFrom commonmark markdown_html @@ -305,8 +274,11 @@ process_text <- function(text, } } -# Find common HTML entities resulting from HTML escaping and -# restore them back to ascii characters +#' Reverse HTML escaping +#' +#' Find common HTML entities resulting from HTML escaping and restore them back +#' to ASCII characters +#' @noRd unescape_html <- function(text) { text %>% @@ -315,7 +287,8 @@ unescape_html <- function(text) { tidy_gsub("&", "&") } -#' Transform Markdown text to HTML; also performs HTML escaping +#' Transform Markdown text to HTML and also perform HTML escaping +#' #' @importFrom commonmark markdown_html #' @noRd md_to_html <- function(x) { @@ -331,8 +304,11 @@ md_to_html <- function(x) { x } -# Transform Markdown text to LaTeX; also escapes ASCII -# characters with special meaning in LaTeX +#' Transform Markdown text to LaTeX +#' +#' In addition to the Markdown-to-LaTeX text transformation, +#' `markdown_to_latex()` also escapes ASCII characters with special meaning in +#' LaTeX. #' @importFrom commonmark markdown_latex #' @noRd markdown_to_latex <- function(text) { @@ -360,7 +336,8 @@ markdown_to_latex <- function(text) { unname() } -# Transform Markdown text to plain text +#' Transform Markdown text to plain text +#' #' @importFrom commonmark markdown_text #' @noRd markdown_to_text <- function(text) { @@ -388,21 +365,36 @@ markdown_to_text <- function(text) { unname() } -# Get prepending and appending text based on a simple pattern -get_pre_post_txt <- function(pattern) { - - prefix <- strsplit(pattern, "\\{x\\}")[[1]][1] - suffix <- strsplit(pattern, "\\{x\\}")[[1]][2] - - prefix <- ifelse(is.na(prefix), "", prefix) - suffix <- ifelse(is.na(suffix), "", suffix) - - c(prefix, suffix) +#' Handle formatting of a pattern in a \code{fmt_*()} function +#' +#' Within the context of a \code{fmt_*()} function, we always have the +#' single-length character vector of \code{pattern} available to describe a +#' final decoration of the formatted values. We use \pkg{glue}'s semantics here +#' and reserve \code{x} to be the formatted values, and, we can use \code{x} +#' multiple times in the pattern. +#' @param pattern A formatting pattern that allows for decoration of the +#' formatted value (defined here as \code{x}). +#' @param values The values (as a character vector) that are formatted within +#' the \code{fmt_*()} function. +#' @noRd +apply_pattern_fmt_x <- function(pattern, + values) { + + vapply( + values, + function(x) tidy_gsub(x = pattern, "{x}", x, fixed = TRUE), + FUN.VALUE = character(1), + USE.NAMES = FALSE + ) } +#' Get a vector of indices for large-number suffixing +#' #' @importFrom utils head #' @noRd -non_na_index <- function(values, index, default_value = NA) { +non_na_index <- function(values, + index, + default_value = NA) { if (is.logical(index)) { index <- is.integer(index) @@ -445,7 +437,7 @@ non_na_index <- function(values, index, default_value = NA) { encoded$values <- ifelse( encoded$values == -Inf, - c(default_value, utils::head(encoded$values, -1)), + c(default_value, head(encoded$values, -1)), encoded$values ) @@ -456,16 +448,17 @@ non_na_index <- function(values, index, default_value = NA) { positions[index] } -# This function operates on a vector of numerical -# values and returns a tibble where each row -# represents a scaled values for `x` and the -# correct suffix to use during x's character-based -# formatting +#' Get a tibble of scaling values and suffixes +#' +#' The `num_suffix()` function operates on a vector of numerical values and +#' returns a tibble where each row represents a scaled value for `x` and the +#' correct suffix to use during `x`'s character-based formatting #' @importFrom dplyr tibble #' @noRd num_suffix <- function(x, suffixes = c("K", "M", "B", "T"), - base = 1000) { + base = 1000, + scale_by) { # If `suffixes` is a zero-length vector, we # provide a tibble that will ultimately not @@ -474,7 +467,7 @@ num_suffix <- function(x, return( dplyr::tibble( - scale_by = rep_len(1, length(x)), + scale_by = rep_len(scale_by, length(x)), suffix = rep_len("", length(x)) ) ) @@ -531,19 +524,28 @@ num_suffix <- function(x, ) } -# Create an `isFALSE`-based helper function that -# works with earlier versions of R (the `isFALSE()` -# function was introduced in R 3.5.0) +#' An `isFALSE`-based helper function +#' +#' The `is_false()` function is similar to the `isFALSE()` function that was +#' introduced in R 3.5.0 except that this implementation works with earlier +#' versions of R. +#' @param x The single value to test for whether it is `FALSE`. +#' @noRd is_false = function(x) { is.logical(x) && length(x) == 1L && !is.na(x) && !x } -# This function normalizes the `suffixing` input to a -# character vector which is later appended to scaled -# numerical values; the input can either be a single -# logical value or a character vector -normalize_suffixing_inputs <- function(suffixing) { +#' Normalize all suffixing input values +#' +#' This function normalizes the `suffixing` input to a character vector which is +#' later appended to scaled numerical values; the input can either be a single +#' logical value or a character vector +#' @param suffixing,scale_by The `suffixing` and `scale_by` options in some +#' `fmt_*()` functions. +#' @noRd +normalize_suffixing_inputs <- function(suffixing, + scale_by) { if (is_false(suffixing)) { @@ -554,16 +556,21 @@ normalize_suffixing_inputs <- function(suffixing) { } else if (isTRUE(suffixing)) { + # Issue a warning if `scale_by` is not 1.0 (the default) + warn_on_scale_by_input(scale_by) + # If `suffixing` is TRUE, return the default # set of suffixes return(c("K", "M", "B", "T")) } else if (is.character(suffixing)) { + # Issue a warning if `scale_by` is not 1.0 (the default) + warn_on_scale_by_input(scale_by) + # In the case that a character vector is provided # to `suffixing`, we first want to check if there # are any names provided - # TODO: found that the conditional below seems # better than other solutions to determine whether # the vector is even partially named @@ -588,7 +595,22 @@ normalize_suffixing_inputs <- function(suffixing) { } } -# Derive a label based on a formula or a function name +#' If performing large-number suffixing, warn on `scale_by` != 1 +#' +#' @param scale_by The `scale_by` option in some `fmt_*()` functions. +#' @noRd +warn_on_scale_by_input <- function(scale_by) { + + if (scale_by != 1) { + warning("The value for `scale_by` cannot be changed if `suffixing` is ", + "anything other than `FALSE`. The value provided to `scale_by` ", + "will be ignored.", + call. = FALSE) + } +} + +#' Derive a label based on a formula or a function name +#' #' @import rlang #' @noRd derive_summary_label <- function(fn) { @@ -612,21 +634,25 @@ derive_summary_label <- function(fn) { } #nocov start - -# This function is a conveient wrapper for `system.file()` where the `package` -# refers to this package +#' A `system.file()` replacement specific to this package +#' +#' This is a conveient wrapper for `system.file()` where the `package` refers to +#' this package. +#' @noRd system_file <- function(file) { system.file(file, package = "gt") } - #nocov end -# This function removes entire HTML tags from input text +#' Remove all HTML tags from input text +#' +#' @noRd remove_html <- function(text) { gsub("<.+?>", "", text) } -# This function transforms a CSS stylesheet to a tibble representation +#' Transform a CSS stylesheet to a tibble representation +#' #' @importFrom dplyr bind_rows tibble filter mutate case_when select pull #' @importFrom stringr str_remove str_extract str_trim str_detect #' @noRd @@ -683,7 +709,8 @@ get_css_tbl <- function(data) { css_tbl } -# Create an inlined style block from a CSS tibble +#' Create an inlined style block from a CSS tibble +#' #' @importFrom dplyr filter select distinct mutate pull #' @importFrom stringr str_split #' @noRd @@ -709,7 +736,8 @@ create_inline_styles <- function(class_names, "\"") } -# Transform HTML to inlined HTML using a CSS tibble +#' Transform HTML to inlined HTML using a CSS tibble +#' #' @importFrom stringr str_extract str_replace str_match #' @noRd inline_html_styles <- function(html, css_tbl) { @@ -776,6 +804,11 @@ inline_html_styles <- function(html, css_tbl) { html } +#' Split any strings that are values in scientific notation +#' +#' @param x_str The input character vector of values formatted in scientific +#' notation. +#' @noRd split_scientific_notn <- function(x_str) { exp_parts <- strsplit(x_str, "e|E") @@ -785,14 +818,25 @@ split_scientific_notn <- function(x_str) { list(num = num_part, exp = exp_part) } -# This function is wrapper for `gsub()` that uses default argument values and -# rearranges first three arguments for better pipelining -tidy_gsub <- function(x, pattern, replacement) { +#' Wrapper for `gsub()` where `x` is the first argument +#' +#' This function is wrapper for `gsub()` that uses default argument values and +#' rearranges first three arguments for better pipelining +#' @param x,pattern,replacement,fixed Select arguments from the `gsub()` +#' function. +#' @noRd +tidy_gsub <- function(x, pattern, replacement, fixed = FALSE) { - gsub(pattern, replacement, x) + gsub(pattern, replacement, x, fixed = fixed) } -# Options setter for the `opts_df` data frame +#' An options setter for the `opts_df` data frame +#' +#' @param opts_df The `opts_df` data frame. +#' @param option The option name; a unique value in the `parameter` column of +#' `opts_df`. +#' @param value The value to set for the given `option`. +#' @noRd opts_df_set <- function(opts_df, option, value) { opts_df[which(opts_df$parameter == option), "value"] <- value @@ -800,13 +844,21 @@ opts_df_set <- function(opts_df, option, value) { opts_df } -# Options getter for the `opts_df` data frame +#' An options getter for the `opts_df` data frame +#' +#' @inheritParams opts_df_set +#' @noRd opts_df_get <- function(opts_df, option) { opts_df[which(opts_df$parameter == option), "value"] } -# Upgrade `cells_*()` to a list() if a single instance provided +#' Upgrader function for `cells_*` objects +#' +#' Upgrade a `cells_*` object to a `list()` if only a single instance is +#' provided. +#' @param locations Any `cells_*` object. +#' @noRd as_locations <- function(locations) { if (!inherits(locations, "location_cells")) { @@ -824,6 +876,9 @@ as_locations <- function(locations) { locations } +#' Create a vector of glyphs to use for footnotes +#' +#' @noRd footnote_glyphs <- function(x, glyphs) { @@ -849,9 +904,14 @@ footnote_glyphs <- function(x, glyphs_val, glyphs_rep, FUN = function(val_i, rep_i) { paste(rep(val_i, rep_i), collapse = "")} - ) %>% unname() + ) %>% + unname() } +#' Determine whether an object is a `gt_tbl` +#' +#' @param data A table object that is created using the \code{\link{gt}()} +#' function. #' @importFrom checkmate test_class #' @noRd is_gt <- function(data) { @@ -859,6 +919,11 @@ is_gt <- function(data) { checkmate::test_class(data, "gt_tbl") } +#' Stop any function if object is not a `gt_tbl` object +#' +#' @param data A table object that is created using the \code{\link{gt}()} +#' function. +#' @noRd stop_if_not_gt <- function(data) { if (!is_gt(data)) { diff --git a/R/utils_formatters.R b/R/utils_formatters.R new file mode 100644 index 0000000000..99c548b363 --- /dev/null +++ b/R/utils_formatters.R @@ -0,0 +1,369 @@ +#' Filter an internal table to a single row with filtering expressions +#' +#' @param table The table to filter down to one row. +#' @param column The column from which the single value should be obtained. +#' @param ... The arguments passed to `dplyr::filter()` +#' @import rlang +#' @importFrom dplyr filter +#' @noRd +filter_table_to_value <- function(table, column, ...) { + + filter_args_enquos <- rlang::enquos(...) + column_enquo <- rlang::enquo(column) + + filtered_tbl <- dplyr::filter(table, !!!filter_args_enquos) + + if (nrow(filtered_tbl) != 1) { + stop("Internal error in `gt:::filter_table_to_row()`:\n", + " * The filtered table doesn't result in a table of exactly one row. ", + "Found ", nrow(filtered_tbl), " rows.", + call. = FALSE) + } + + filtered_tbl %>% + dplyr::pull(!!column_enquo) +} + +#' Validate the user-supplied `locale` value +#' +#' @param locale The user-supplied `locale` value, found in several `fmt_*()` +#' functions. This is expected as `NULL` if not supplied by the user. +#' @noRd +validate_locale <- function(locale) { + + # Stop function if the `locale` provided + # isn't a valid one + if (!(locale %in% locales$base_locale_id)) { + stop("The supplied `locale` is not available in the list of supported locales.\n", + " * Use the `info_locales()` function to see which locales can be used.", + call. = FALSE) + } +} + +#' Validate the user-supplied `currency` value +#' +#' @param currency The user-supplied `currency` value, found in the +#' `fmt_currency()` function. +#' @noRd +validate_currency <- function(currency) { + + # Stop function if the `currency` provided + # isn't a valid one + if (!( + as.character(currency) %in% currency_symbols$curr_symbol | + as.character(currency) %in% currencies$curr_code | + as.character(currency) %in% currencies$curr_number)) { + stop("The supplied `currency` is not available in the list of supported currencies.\n", + " * Use the `info_currencies()` function to see which currencies can be used.\n", + " * See `?fmt_currency` to understand which input types are valid.", + call. = FALSE) + } +} + +#' Get the `sep_mark` value based on a locale +#' +#' @param locale The user-supplied `locale` value, found in several `fmt_*()` +#' functions. This is expected as `NULL` if not supplied by the user. +#' @param default The default value for the `sep_mark`. +#' @param use_seps A logical value for whether to use separators at all. +#' @importFrom dplyr filter pull +#' @noRd +get_locale_sep_mark <- function(locale = NULL, + default, + use_seps) { + + # If `use_seps` is FALSE, then force + # `sep_mark` to be an empty string + if (!use_seps) { + return("") + } + + # If `locale` is NULL then return the + # default `sep_mark` + if (is.null(locale)) { + return(default) + } + + # Stop function if the `locale` provided + # isn't a valid one + validate_locale(locale) + + # Get the correct `group_sep` value from the + # `gt:::locales` lookup table + sep_mark <- + filter_table_to_value(locales, group_sep, base_locale_id == locale) + + # TODO: Modify `locales` table to replace `""` with + # `" "` in `group_sep` column; once that is done, the + # below statement can be safely removed + if (sep_mark == "") sep_mark <- " " + + sep_mark +} + +#' Get the `dec_mark` value based on a locale +#' +#' @param locale The user-supplied `locale` value, found in several `fmt_*()` +#' functions. This is expected as `NULL` if not supplied by the user. +#' @param default The default value for the `dec_mark`. +#' @importFrom dplyr filter pull +#' @noRd +get_locale_dec_mark <- function(locale = NULL, + default) { + + # If `locale` is NULL then return the + # default `dec_mark` + if (is.null(locale)) { + return(default) + } + + # Stop function if the `locale` provided + # isn't a valid one + validate_locale(locale) + + # Get the correct `dec_sep` value from the + # `gt:::locales` lookup table + filter_table_to_value(locales, dec_sep, base_locale_id == locale) +} + +#' Determine which numbers in scientific notation would be zero order +#' +#' @param x A vector of numeric values, including `NA` values +#' @noRd +has_order_zero <- function(x) { + + ( + (x >= 1 & x < 10) | (x <= -1 & x > -10) | x == 0 + ) & !is.na(x) +} + +#' @noRd +get_currency_decimals <- function(currency, + decimals, + use_subunits) { + + # Get the number of decimal places + if (is.null(decimals) && use_subunits) { + + # Get decimal places using `get_currency_exponent()` fcn + if (currency %in% currency_symbols$curr_symbol) { + + return(2) + + } else { + + return(get_currency_exponent(currency)) + } + + } else if (is.null(decimals) && !use_subunits) { + + return(0) + + } else { + return(decimals) + } +} + +#' Apply a scaling factor to a vector of numeric values +#' +#' @param x A vector of numeric values. +#' @param scale_by A numeric scalar. +#' @noRd +scale_x_values <- function(x, + scale_by) { + checkmate::assert_numeric( + scale_by, + finite = TRUE, + any.missing = FALSE) + + len <- length(scale_by) + + # Stop function if the length of `scale_by` + # is not 1 of the length of `x` + if (!any(len == 1, len == length(x))) { + stop("The length of the `scale_by` vector must be 1 or the length of `x`.", + call. = FALSE) + } + + x * scale_by +} + +#' A `formatC()` call for `fmt_number()` and `fmt_percent()` +#' +#' @param x A vector of numeric values. +#' @param decimals The number of decimal places (`digits`). +#' @param sep_mark The separator for number groups (`big.mark`). +#' @param dec_mark The decimal separator mark (`decimal.mark`). +#' @param format The numeric format for `formatC()`. +#' @param drop_trailing_zeros Option to exclude trailing decimal zeros. +#' @noRd +format_num_to_str <- function(x, + decimals, + sep_mark, + dec_mark, + drop_trailing_zeros, + format = "f") { + + formatC( + x = x, + digits = decimals, + mode = "double", + big.mark = sep_mark, + decimal.mark = dec_mark, + format = format, + drop0trailing = drop_trailing_zeros + ) +} + +#' A `formatC()` call for `fmt_scientific()` +#' +#' @inheritParams format_num_to_str +#' @noRd +format_num_to_str_e <- function(x, + decimals, + sep_mark, + dec_mark, + drop_trailing_zeros) { + + format_num_to_str( + x, + decimals, + sep_mark, + dec_mark, + format = "e", + drop_trailing_zeros) +} + +#' A `formatC()` call for `fmt_currency()` +#' +#' @inheritParams format_num_to_str +#' @noRd +format_num_to_str_c <- function(x, + decimals, + sep_mark, + dec_mark) { + + format_num_to_str( + x, + decimals, + sep_mark, + dec_mark, + format = "f", + drop_trailing_zeros = FALSE) +} + +#' Surround formatted values with `$`s for LaTeX +#' +#' @noRd +to_latex_math_mode <- function (x) { + + x %>% + paste_between(x_2 = c("$", "$")) +} + +context_minus_mark <- function(context) { + + switch(context, + html = "−", + "-") +} + +context_negative_currency_mark <- function(context) { + + switch(context, + html = "−", + "-") +} + +context_parens_marks <- function(context) { + + switch(context, + html = c("(", ")"), + latex = c("\\left(", "\\right)"), + c("(", ")")) +} + +context_parens_marks_number <- function(context) { + + switch(context, + html = c("(", ")"), + latex = c("(", ")"), + c("(", ")")) +} + +context_exp_marks <- function(context) { + + switch(context, + html = c(" × 10", ""), + latex = c(" \\times 10^{", "}"), + c(" x 10(", ")")) +} + +context_percent_mark <- function(context) { + + switch(context, + html = "%", + latex = "\\%", + "%") +} + +context_currency_str_regex <- function(context) { + + switch(context, + latex = "\\\\$", + "\\$") +} + +context_currency_str <- function(context, currency) { + + switch(context, + html = { + get_currency_str(currency) + }, + latex = { + currency %>% + get_currency_str(fallback_to_code = TRUE) %>% + markdown_to_latex() %>% + paste_between(x_2 = c("\\text{", "}")) + }, + { + currency %>% + get_currency_str(fallback_to_code = TRUE) + }) +} + +paste_currency_str <- function(x, + currency_str, + incl_space, + placement) { + + vapply(FUN.VALUE = character(1), USE.NAMES = FALSE, x, function(x) { + + if (grepl("^-", x)) { + + x %>% + tidy_gsub("^-", "") %>% + paste_on_side( + x_side = ifelse(incl_space, " ", ""), + direction = placement + ) %>% + paste_on_side( + x_side = currency_str, + direction = placement + ) %>% + paste_left("-") + + } else { + + x %>% + paste_on_side( + x_side = ifelse(incl_space, " ", ""), + direction = placement + ) %>% + paste_on_side( + x_side = currency_str, + direction = placement + ) + } + }) +} diff --git a/R/utils_general_str_formatting.R b/R/utils_general_str_formatting.R new file mode 100644 index 0000000000..d35dfde4c8 --- /dev/null +++ b/R/utils_general_str_formatting.R @@ -0,0 +1,317 @@ +###### +# General String Formatters +###### + +#' Flexibly split a string into two pieces +#' +#' @param x The string to split into a character vector of length 2. +#' @param before,after Either an exact numeric position for where splitting will +#' occur, or a regular expression to match on a range of characters. We can +#' use either `before` or `after` (but not both) with this variable input to +#' accurately define which side of the match is the split position. +#' @noRd +split_string_2 <- function(x, + before = NULL, + after = NULL) { + + # Stop function if `x` is not of class character + if (!inherits(x, "character")) { + stop("Internal error in `gt:::paste_within()`:\n", + "* The `x` object must be of class character.", + call. = FALSE) + } + + # Stop function if the length of `x` is not 1 + if (length(x) != 1) { + stop("Internal error in `gt:::paste_within()`:\n", + "* The length of the `x` must be exactly 1.", + call. = FALSE) + } + + # Get the length of the string `x` + x_length <- nchar(x) + + # If neither of `before` or `after` has a value, + # stop the function + if (is.null(before) && is.null(after)) { + stop("Internal error in `gt:::split_string_2()`:\n", + " * Both `before` and `after` cannot be `NULL`.", + call. = FALSE) + } + + # If both `before` and `after` have values, stop + # the function + if (!is.null(before) && !is.null(after)) { + stop("Internal error in `gt:::split_string_2()`:\n", + " * A value must be provided to either `before` or `after`, not both.", + call. = FALSE) + } + + # Collapse value for either `before` or `after`; + # add a class to retain the direction-of-split + # information + if (!is.null(before)) { + input <- before + class(input) <- c("before", class(before)) + } else if (!is.null(after)) { + input <- after + class(input) <- c("after", class(after)) + } + + if (inherits(input, "character")) { + + # Use the pattern (`input`) with the input string + # `x` with `regexpr()` to get the matching output + regexpr_out <- regexpr(input, x) + + # If there is no match, return a character vector + # of length 2 (original string, then empty string) + if (as.numeric(regexpr_out) == -1) { + return(c(x, "")) + } + + # Define the start position for the matched characters + split_start <- + regexpr_out %>% + as.numeric() + + # Define the stop position for the matched characters + split_stop <- + attr(regexpr_out, "match.length", exact = TRUE) + split_start - 1 + + } else if (inherits(input, "numeric")) { + + # Stop function if the index position is not valid + if (input > x_length) { + stop("Internal error in `gt:::split_string_2()`:\n", + "* The numeric value provided cannot be greater than ", x_length, ".", + call. = FALSE) + } + + # Define the start and stop positions as + # the single `input` value + split_start <- split_stop <- input %>% as.numeric() + } + + # Perform the split either before the matched characters + if (inherits(input, "before")) { + + x_2 <- c(substr(x, 0, split_start - 1), substr(x, split_start, x_length)) + + } else if (inherits(input, "after")) { + + x_2 <- c(substr(x, 0, split_stop), substr(x, split_stop + 1, x_length)) + } + + x_2 +} + +#' Flexibly split a string into two pieces +#' +#' @param x A character vector that is to be pasted between the +#' first and second elements of `x_2`. +#' @param x_2 A character vector of length 2. +#' @noRd +paste_between <- function(x, + x_2) { + + # Stop function if `x_2` is not of class character + if (!inherits(x_2, "character")) { + stop("Internal error in `gt:::paste_between()`:\n", + "* The `x_2` object must be of class character.", + call. = FALSE) + } + + # Stop function if the length of `x_2` is not 2 + if (length(x_2) != 2) { + stop("Internal error in `gt:::paste_between()`:\n", + "* The length of the `x_2` must be exactly 2.", + call. = FALSE) + } + + # Stop function if `x` is not of class character + if (!inherits(x, "character")) { + stop("Internal error in `gt:::paste_between()`:\n", + "* The `x` object must be of class character.", + call. = FALSE) + } + + paste0(x_2[1], x, x_2[2]) +} + +#' Paste a string either onto the left or the right of another string +#' +#' @param x A character vector of length equal to that of `x_side`. +#' @param x_side Another character vector, with a length equal to that of `x`. +#' It will be pasted either to the left or to the right of `x` depending on +#' the `direction`. +#' @param direction The side that `x_side` will be relative to `x`. This can +#' be `left` or `right`. +#' @noRd +paste_on_side <- function(x, + x_side, + direction) { + + # Stop function if `direction` is not valid + if (!(direction %in% c("left", "right"))) { + stop("Internal error in `gt:::paste_on_side()`:\n", + "* The `direction` must be either `left` or `right`.", + call. = FALSE) + } + + # Stop function if `x` and `x_side` are not both of class character + if (any(!inherits(x, "character"), !inherits(x_side, "character"))) { + stop("Internal error in `gt:::paste_on_side()`:\n", + "* The `x` and `x_side` objects must be of class character.", + call. = FALSE) + } + + len <- length(x_side) + + # Stop function if the length of `x_side` is not 1 of the length of `x` + if (!any(len == 1, len == length(x))) { + stop("The length of the `x_side` vector must be 1 or the length of `x`.", + call. = FALSE) + } + + if (direction == "left") { + + return(paste0(x_side, x)) + + } else if (direction == "right") { + + return(paste0(x, x_side)) + } +} + +#' Paste a string onto the left side of another string +#' +#' @inheritParams paste_on_side +#' @param x_left Another character vector of length 1 that is to be pasted to +#' the left of `x`. +#' @noRd +paste_left <- function(x, x_left) { + paste_on_side(x, x_side = x_left, direction = "left") +} + +#' Paste a string onto the right side of another string +#' +#' @inheritParams paste_on_side +#' @param x_right Another character vector of length 1 that is to be pasted to +#' the right of `x`. +#' @noRd +paste_right <- function(x, x_right) { + paste_on_side(x, x_side = x_right, direction = "right") +} + +#' Swap adjacent text groups +#' +#' @param x A text string. +#' @param pattern_1,pattern_2 Regular expression to match on a range of +#' characters. The order of regex patterns does not need to be in the order of +#' matching in `x`. +#' @noRd +swap_adjacent_text_groups <- function(x, + pattern_1, + pattern_2) { + + # Stop function if `x` is not of class character + if (!inherits(x, "character")) { + stop("Internal error in `gt:::paste_within()`:\n", + "* The `x` object must be of class character.", + call. = FALSE) + } + + vapply(x, function(x) { + + # Return `x` as is if both patterns aren't present + if (is_false(grepl(pattern_1, x)) || is_false(grepl(pattern_2, x))) { + return(x) + } + + # Get the start and stop positions for the text groups + group_1 <- x %>% get_start_stop_positions(pattern = pattern_1) + group_2 <- x %>% get_start_stop_positions(pattern = pattern_2) + + # Return `x` as is if the patterns don't encompass text ranges + # that aren't adjacent + if (!is_adjacent_separate(group_1, group_2)) { + return(x) + } + + # Obtain a length-two vector of text groups based on the + # extracted substrings + substr <- + c( + substring(x, group_1[1], group_1[2]), + substring(x, group_2[1], group_2[2]) + ) + + # Reverse the order of the elements in `substr` + # if necessary and paste elements together + if (group_1[1] < group_2[1]) { + rev_group <- paste0(rev(substr), collapse = "") + } else { + rev_group <- paste0(substr, collapse = "") + } + + # Get the character indices that the contiguous text + # groups encompass + group_pos <- min(group_1, group_2):max(group_1, group_2) + + # Return the reversed set of patterns + paste0( + substring(x, 0, min(group_pos) - 1), + rev_group, + substring(x, max(group_pos) + 1, nchar(x)), + collapse = "" + ) + }, + FUN.VALUE = character(1), + USE.NAMES = FALSE + ) +} + +#' Get the start and stop positions for a text match +#' +#' @param x A text string. +#' @param pattern A regular expression pattern. +#' @noRd +get_start_stop_positions <- function(x, + pattern) { + + # Use the pattern (`input`) with the input string + # `x` with `regexpr()` to get the matching output + regexpr_out <- regexpr(pattern, x) + + # Define the start position for the matched characters + start_pos <- regexpr_out %>% as.numeric() + + # Define the stop position for the matched characters + stop_pos <- attr(regexpr_out, "match.length", exact = TRUE) + start_pos - 1 + + # Return a vector of length 2 + c(start_pos, stop_pos) +} + +#' Determine if text groups are adjacent and non-overlapping +#' +#' @param group_1,group_2 Vectors of length 2 with starting and stopping +#' positions in a text string. +#' @noRd +is_adjacent_separate <- function(group_1, + group_2) { + + group_1_expanded <- seq(group_1[1], group_1[2]) + group_2_expanded <- seq(group_2[1], group_2[2]) + + if (length(base::intersect(group_1_expanded, group_2_expanded)) > 0) { + return(FALSE) + } + + if (any(diff(sort(c(group_1_expanded, group_2_expanded))) > 1)) { + return(FALSE) + } + + return(TRUE) +} diff --git a/R/utils_render_common.R b/R/utils_render_common.R index a6df42efd2..5d636bb6b6 100644 --- a/R/utils_render_common.R +++ b/R/utils_render_common.R @@ -400,7 +400,7 @@ create_summary_dfs <- function(summary_list, # Resolve the columns to exclude columns_excl <- base::setdiff(colnames(output_df), columns) - # Combine `groupname` with the field data in order to + # Combine `groupname` with the table body data in order to # process data by groups if (groups[1] != "::GRAND_SUMMARY") { @@ -737,7 +737,7 @@ process_source_notes <- function(source_note, context) { } } -# Function to build a vector of `group` rows in the table field +# Function to build a vector of `group` rows in the table body create_group_rows <- function(n_rows, groups_rows_df, context = "latex") { @@ -760,7 +760,7 @@ create_group_rows <- function(n_rows, unname() } -# Function to build a vector of `data` rows in the table field +# Function to build a vector of `data` rows in the table body create_data_rows <- function(n_rows, row_splits, context = "latex") { @@ -777,7 +777,7 @@ create_data_rows <- function(n_rows, unname() } -# Function to build a vector of `summary` rows in the table field +# Function to build a vector of `summary` rows in the table body create_summary_rows <- function(n_rows, n_cols, list_of_summaries, diff --git a/R/utils_render_html.R b/R/utils_render_html.R index 6f4ebbfcf3..d44008c7c4 100644 --- a/R/utils_render_html.R +++ b/R/utils_render_html.R @@ -1,9 +1,14 @@ -# Transform a footnote glyph to an HTML representation as a superscript + +#' Transform a footnote glyph to an HTML representation +#' +#' @noRd footnote_glyph_to_html <- function(footnote_glyph) { paste0("", footnote_glyph, "") } +#' Get the spanner column label style from an attribute table +#' #' @importFrom dplyr filter pull #' @noRd get_spanner_style <- function(spanner_style_attrs, @@ -23,6 +28,8 @@ get_spanner_style <- function(spanner_style_attrs, } } +#' Get the column label style from an attribute table +#' #' @importFrom dplyr filter pull #' @noRd get_column_style <- function(column_style_attrs, @@ -42,6 +49,9 @@ get_column_style <- function(column_style_attrs, } } +#' Create a set of inline style attributes +#' +#' @noRd create_style_attrs <- function(style_values) { style_rules <- c() @@ -58,15 +68,19 @@ create_style_attrs <- function(style_values) { style_rules } -# Taking the `body_content` vector, split into list components with one -# item per row in the output table +#' Split the body content vector into a list structure +#' +#' Taking the `body_content` vector, split into list components with one item +#' per row in the output table +#' @noRd split_body_content <- function(body_content, n_cols) { split(body_content, ceiling(seq_along(body_content) / n_cols)) } -# Apply footnotes to the data rows +#' Apply footnotes to the data rows +#' #' @importFrom dplyr filter group_by mutate ungroup select distinct #' @noRd apply_styles_to_output <- function(output_df, @@ -113,7 +127,8 @@ apply_styles_to_output <- function(output_df, split_body_content(body_content = body_styles, n_cols) } -#' Apply styles to summary rows +#' Apply footnotes to the summary data cells +#' #' @importFrom dplyr filter group_by mutate ungroup select distinct #' @noRd apply_styles_to_summary_output <- function(summary_df, @@ -204,9 +219,11 @@ create_table_start_h <- function(groups_rows_df) { "\n\n" } -# Create the heading component of a table, which contains the heading and -# possibly a subtitle; if there are no heading components defined this -# function will return an empty string +#' Create the heading component of a table +#' +#' The table heading component contains the heading and possibly a subtitle; if +#' there are no heading components defined this function will return an empty +#' string. #' @importFrom dplyr filter group_by mutate ungroup select distinct #' @noRd create_heading_component <- function(heading, @@ -405,7 +422,8 @@ create_heading_component <- function(heading, heading_component } -# Create the columns component of a table +#' Create the columns component of a table (HTML) +#' #' @import rlang #' @importFrom dplyr filter group_by mutate ungroup select distinct #' @noRd @@ -615,6 +633,8 @@ create_columns_component_h <- function(boxh_df, table_col_headings } +#' Create the table body component (HTML) +#' #' @importFrom dplyr mutate filter pull #' @noRd create_body_component_h <- function(row_splits_body, @@ -637,7 +657,7 @@ create_body_component_h <- function(row_splits_body, stub_available <- TRUE } - # Get the sequence of column numbers in the data field + # Get the sequence of column numbers in the table body column_series <- seq(n_cols) # If there is a stub, remove the last element in the series @@ -856,6 +876,9 @@ create_body_component_h <- function(row_splits_body, "\n") } +#' Create the table source note component (HTML) +#' +#' @noRd create_source_note_component_h <- function(source_note, n_cols) { @@ -874,6 +897,8 @@ create_source_note_component_h <- function(source_note, "\n") } +#' Create the table footnote component (HTML) +#' #' @importFrom dplyr select distinct filter pull #' @noRd create_footnote_component_h <- function(footnotes_resolved, @@ -911,7 +936,9 @@ create_footnote_component_h <- function(footnotes_resolved, footnote_component } -# Create the closing HTML element of a table +#' Create the closing HTML element of a table +#' +#' @noRd create_table_end_h <- function() { "
\n\n" diff --git a/R/utils_render_latex.R b/R/utils_render_latex.R index 649d615cab..c4b8c84893 100644 --- a/R/utils_render_latex.R +++ b/R/utils_render_latex.R @@ -1,7 +1,7 @@ # Create a vector of LaTeX packages to use as table dependencies latex_packages <- function() { - c("longtable", "booktabs", "caption") + c("amsmath", "booktabs", "caption", "longtable") } # Transform a footnote glyph to a LaTeX representation as a superscript diff --git a/docs/CNAME b/docs/CNAME deleted file mode 100644 index 88f0126067..0000000000 --- a/docs/CNAME +++ /dev/null @@ -1 +0,0 @@ -gt.rstudio.com \ No newline at end of file diff --git a/docs/CODE_OF_CONDUCT.html b/docs/CODE_OF_CONDUCT.html deleted file mode 100644 index e7fed4ed20..0000000000 --- a/docs/CODE_OF_CONDUCT.html +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - -Contributor Code of Conduct ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - -
- -
-
- - -
- -

As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.

-

We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.

-

Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.

-

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.

-

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.

-

This Code of Conduct is adapted from the Contributor Covenant (http://contributor-covenant.org), version 1.0.0, available at http://contributor-covenant.org/version/1/0/0/

-
- -
- -
- - - -
- - - - - - diff --git a/docs/CONTRIBUTING.html b/docs/CONTRIBUTING.html deleted file mode 100644 index 5de335d518..0000000000 --- a/docs/CONTRIBUTING.html +++ /dev/null @@ -1,184 +0,0 @@ - - - - - - - - -Information and Guidelines for Contributing to gt ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - -
- -
-
- - -
- -

There are many ways to contribute to the ongoing development of the gt package. Some contributions can be rather easy to do (e.g., fixing typos, improving documentation, filing issues for feature requests or problems, etc.) whereas other contributions can require more time and patience (like answering questions and submitting pull requests with code changes). Just know that that help provided in any capacity is very much appreciated. :)

-
-

-Filing Issues

-

If you believe you found a bug, create a minimal reprex for your posting to the gt issue tracker. Try not to include anything unnecessary, just the minimal amount of code that constitutes the reproducible bug. We will try to verify the bug by running the code in the reprex provided. The quality of the reprex will reduce the amount of back-and-forth communication in trying to understand how to execute the code on our systems.

-
-
-

-Answering questions

-

A great way to help is by simply answering questions. Itā€™s amazing how a little conversation could lead to better insights on a problem. Donā€™t quite know the answer? Thatā€™s okay too. Weā€™re all in this together.

-

Where might you answer user questions? Some of the forums for Q&A on gt include the RStudio community, on Twitter (a good search term is gt #rstats), and on Stack Overflow. Good etiquette is key during these interactions: be a good person to all who ask questions.

-
-

-Making Pull Requests

-

Should you consider making a pull request (PR), please file an issue first and explain the problem in some detail. If the PR is an enhancement, detail how the change would make things better for package users. Bugfix PRs also requre some explanation about the bug and how the proposed fix will remove that bug. A great way to illustrate the bug is to include a reprex. While all this upfront work prior to preparing a PR can be time-consuming it opens a line of communication with the package authors and the community, perhaps leading to better enhancement or more effective fixes!

-

Once there is consensus that a PR based on the issue would be helpful, adhering to the following process will make things proceed more quickly:

-
    -
  • Create a separate Git branch for each PR.
  • -
  • Look at the Travis and AppVeyor build status badges before and after making changes; these badges are available in the package README.
    -
  • -
  • The gt package follows the tidyverse style guide so please adopt those style guidelines in your submitted code as best as possible.
  • -
  • The internal documentation uses roxygen2; if your contribution requires new or revised documentation ensure that the roxygen comments are added/modified (do not modify any .Rd files in the man folder).
  • -
  • We use testthat for code coverage; those contributions with test cases included are helpful easier to accept.
  • -
  • Add a bullet to the top of NEWS.md below the current development version header describing any user-facing changes made; include your GitHub username, and links to relevant issue(s)/PR(s).
  • -
  • Fill out and sign the individual or corporate contributor agreement as appropriate; then send the signed copy to .
  • -
-
-
-
- -
- -
- - - -
- - - - - - diff --git a/docs/ISSUE_TEMPLATE.html b/docs/ISSUE_TEMPLATE.html deleted file mode 100644 index 7af8059066..0000000000 --- a/docs/ISSUE_TEMPLATE.html +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - -NA ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - -
- -
-
- - - -

Please briefly describe your problem or your ideas for enhancement in the template below.

-

Have a question? Please donā€™t use this form but instead ask on RStudio community, on Stack Overflow, or on Twitter (using the #rstats hashtag).

-

When describing a bug, please include a minimal reproducible example (otherwise known as a reprex).

-

When posting, delete these explanatory lines and submit only the text derived from the template below.

-
-

- - - -
- -
- - - -
- - - - - - diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html deleted file mode 100644 index cbeda65ef7..0000000000 --- a/docs/LICENSE-text.html +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - - - -License ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - -
- -
-
- - -
YEAR: 2018
-COPYRIGHT HOLDER: RStudio, Inc
-ORGANIZATION: RStudio, Inc
-
- -
- -
- - - -
- - - - - - diff --git a/docs/LICENSE.html b/docs/LICENSE.html deleted file mode 100644 index 050adad387..0000000000 --- a/docs/LICENSE.html +++ /dev/null @@ -1,160 +0,0 @@ - - - - - - - - -NA ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - -
- -
-
- - - -

The MIT License (MIT)

-

Copyright (c) 2018 RStudio, Inc

-

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ā€œSoftwareā€), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

-

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

-

THE SOFTWARE IS PROVIDED ā€œAS ISā€, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

- - -
- -
- - - -
- - - - - - diff --git a/docs/apple-touch-icon-120x120.png b/docs/apple-touch-icon-120x120.png deleted file mode 100644 index c221547e8f..0000000000 Binary files a/docs/apple-touch-icon-120x120.png and /dev/null differ diff --git a/docs/apple-touch-icon-152x152.png b/docs/apple-touch-icon-152x152.png deleted file mode 100644 index f5fc2c4981..0000000000 Binary files a/docs/apple-touch-icon-152x152.png and /dev/null differ diff --git a/docs/apple-touch-icon-180x180.png b/docs/apple-touch-icon-180x180.png deleted file mode 100644 index d0e740724f..0000000000 Binary files a/docs/apple-touch-icon-180x180.png and /dev/null differ diff --git a/docs/apple-touch-icon-60x60.png b/docs/apple-touch-icon-60x60.png deleted file mode 100644 index 13eef5f42b..0000000000 Binary files a/docs/apple-touch-icon-60x60.png and /dev/null differ diff --git a/docs/apple-touch-icon-76x76.png b/docs/apple-touch-icon-76x76.png deleted file mode 100644 index fa121233d0..0000000000 Binary files a/docs/apple-touch-icon-76x76.png and /dev/null differ diff --git a/docs/apple-touch-icon.png b/docs/apple-touch-icon.png deleted file mode 100644 index cb9e7cba2c..0000000000 Binary files a/docs/apple-touch-icon.png and /dev/null differ diff --git a/docs/articles/case-study-gtcars.html b/docs/articles/case-study-gtcars.html deleted file mode 100644 index bf90562c28..0000000000 --- a/docs/articles/case-study-gtcars.html +++ /dev/null @@ -1,5806 +0,0 @@ - - - - - - - -Case Study: gtcars ā€¢ gt - - - - - - - - - - - - - - - - -
-
- - - -
-
- - - - -

-

-

Letā€™s make a display table using the gtcars dataset. We all know mtcarsā€¦ what is gtcars? Itā€™s basically a modernized mtcars for the gt age. Itā€™s part of the gt package, and here is a preview of the tibble:

- -

For the purpose of simply learning more about gt, letā€™s reduce this 47-row tibble to one that has only 8 rows:

- -

Letā€™s make a display table from this dataset. In doing so weā€™ll fulfill the following 10 requirements:

-
    -
  1. putting the cars into characteristic groups (by the car manufacturerā€™s country of origin)
  2. -
  3. removing some of the columns that we donā€™t want to present
  4. -
  5. incorporating some columns into a column group
  6. -
  7. formatting the currency data and using a monospaced font for easier reading of that data
  8. -
  9. giving the table a title and a subtitle
  10. -
  11. adding footnotes to draw attention to some of the more interesting data points and to explain some of the more unusual aspects of the data
  12. -
  13. placing a citation for the dataset at the bottom of the table
  14. -
  15. transforming the transmission (trsmn) codes so that they are readable and understandable
  16. -
  17. styling some cells according to basic criteria
  18. -
  19. highlighting the cars that are considered to be grand tourers -
  20. -
-
-

-Row Groups

-

Letā€™s again use dplyr to help make groupings by the ctry_origin column, which provides the country of origin for the vehicle manufacturer of the car. We can simply use dplyr::group_by() on the gtcars dataset and pass that to gt(). What you get is a display table that arranges the cars into row groups, with the name of the group displayed prominently above.

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mfrmodelyeartrimbdy_stylehphp_rpmtrqtrq_rpmmpg_cmpg_hdrivetraintrsmnmsrp
United States
FordGT2017Base Coupecoupe647625055059001118rwd7a447000
DodgeViper2017GT Coupecoupe645500060050001219rwd6m95895
Italy
FerrariLaFerrari2015Base Coupecoupe949900066467501216rwd7a1416362
LamborghiniAventador2015LP 700-4 Coupecoupe700825050755001118awd7a397500
Japan
AcuraNSX2017Base Coupecoupe573650047620002122awd9a156000
NissanGT-R2016Premium Coupecoupe545640043632001622awd6a101770
Germany
BMWi82016Mega World Coupecoupe357580042037002829awd6am140700
Mercedes-BenzAMG GT2016S Coupecoupe503625047917501622rwd7a129900
- -
-

Getting the row groups in the preferred order can be done easily with dplyrā€™s arrange() function. For example, we can have groups that are arranged alphabetically by manufacturer (mfr) and then sorted by highest sticker price (msrp) to lowest.

-
gtcars_8 %>%
-  dplyr::group_by(ctry_origin) %>%
-  dplyr::arrange(mfr, desc(msrp)) %>%
-  gt()
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mfrmodelyeartrimbdy_stylehphp_rpmtrqtrq_rpmmpg_cmpg_hdrivetraintrsmnmsrp
Japan
AcuraNSX2017Base Coupecoupe573650047620002122awd9a156000
NissanGT-R2016Premium Coupecoupe545640043632001622awd6a101770
Germany
BMWi82016Mega World Coupecoupe357580042037002829awd6am140700
Mercedes-BenzAMG GT2016S Coupecoupe503625047917501622rwd7a129900
United States
DodgeViper2017GT Coupecoupe645500060050001219rwd6m95895
FordGT2017Base Coupecoupe647625055059001118rwd7a447000
Italy
FerrariLaFerrari2015Base Coupecoupe949900066467501216rwd7a1416362
LamborghiniAventador2015LP 700-4 Coupecoupe700825050755001118awd7a397500
- -
-

We could also use factor levels to get a more particular ordering within arrange(). For example, we can first arrange the groups themselves (the country of originā€“ctry_origin) by our own preferred ordering and then arrange by mfr and descending msrp as before. Then, group_by(ctry_origin) can be used on the sorted tibble before passing this to gt().

-
# Define our preferred order `ctry_origin`
-order_countries <- c("Germany", "Italy", "United States", "Japan")
-
-# Reorder the table rows by our specific ordering of groups
-gtcars_8 %>%
-  dplyr::arrange(
-    factor(ctry_origin, levels = order_countries), mfr, desc(msrp)
-  ) %>%
-  dplyr::group_by(ctry_origin) %>%
-  gt()
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mfrmodelyeartrimbdy_stylehphp_rpmtrqtrq_rpmmpg_cmpg_hdrivetraintrsmnmsrp
Germany
BMWi82016Mega World Coupecoupe357580042037002829awd6am140700
Mercedes-BenzAMG GT2016S Coupecoupe503625047917501622rwd7a129900
Italy
FerrariLaFerrari2015Base Coupecoupe949900066467501216rwd7a1416362
LamborghiniAventador2015LP 700-4 Coupecoupe700825050755001118awd7a397500
United States
DodgeViper2017GT Coupecoupe645500060050001219rwd6m95895
FordGT2017Base Coupecoupe647625055059001118rwd7a447000
Japan
AcuraNSX2017Base Coupecoupe573650047620002122awd9a156000
NissanGT-R2016Premium Coupecoupe545640043632001622awd6a101770
- -
-

The last variation is to combine the manufacturer name with the model name, using those combined strings as row labels for the table. This is just a little more dplyr where we can use dplyr::mutate() to make a new car column followed by dplyr::select() where we remove the mfr and model columns. When introducing the tibble to the gt() function, we can now use the rowname_col argument to specify a column that will serve as row labels (which is the newly made car column).

-
# Reorder the table rows by our specific ordering of groups
-tab <-
-  gtcars_8 %>%
-  dplyr::arrange(
-    factor(ctry_origin, levels = order_countries),
-    mfr, desc(msrp)
-    ) %>%
-  dplyr::mutate(car = paste(mfr, model)) %>%
-  dplyr::select(-mfr, -model) %>%
-  dplyr::group_by(ctry_origin) %>%
-  gt(rowname_col = "car")
-
-# Show the table
-tab
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
yeartrimbdy_stylehphp_rpmtrqtrq_rpmmpg_cmpg_hdrivetraintrsmnmsrp
Germany
BMW i82016Mega World Coupecoupe357580042037002829awd6am140700
Mercedes-Benz AMG GT2016S Coupecoupe503625047917501622rwd7a129900
Italy
Ferrari LaFerrari2015Base Coupecoupe949900066467501216rwd7a1416362
Lamborghini Aventador2015LP 700-4 Coupecoupe700825050755001118awd7a397500
United States
Dodge Viper2017GT Coupecoupe645500060050001219rwd6m95895
Ford GT2017Base Coupecoupe647625055059001118rwd7a447000
Japan
Acura NSX2017Base Coupecoupe573650047620002122awd9a156000
Nissan GT-R2016Premium Coupecoupe545640043632001622awd6a101770
- -
-
-
-

-Hiding and Moving Some Columns

-

Letā€™s hide two columns that we donā€™t need to the final table: drivetrain and bdy_style. We can use the cols_hide() function to hide columns. The same end result might also have been achieved by using gtcars %>% dplyr::select(-c(drivetrain, bdy_style)), before introducing the table to gt(). Why this function then? Sometimes youā€™ll need variables for conditional statements within gt but wonā€™t want to display them in the end.

-

Aside from hiding columns, letā€™s move some of them. Again, this could be done with dplyr::select() but there are options here in gt via the cols_move_to_start(), cols_move(), and cols_move_to_end() functions.

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
yeartrimtrsmnmpg_cmpg_hhphp_rpmtrqtrq_rpmmsrp
Germany
BMW i82016Mega World Coupe6am282935758004203700140700
Mercedes-Benz AMG GT2016S Coupe7a162250362504791750129900
Italy
Ferrari LaFerrari2015Base Coupe7a1216949900066467501416362
Lamborghini Aventador2015LP 700-4 Coupe7a111870082505075500397500
United States
Dodge Viper2017GT Coupe6m12196455000600500095895
Ford GT2017Base Coupe7a111864762505505900447000
Japan
Acura NSX2017Base Coupe9a212257365004762000156000
Nissan GT-R2016Premium Coupe6a162254564004363200101770
- -
-
-
-

-Putting Columns Into Groups

-

Itā€™s sometimes useful to arrange variables/columns into groups by using spanner column labels. This can be done in gt by using the tab_spanner() function. It takes the label and columns arguments; label is the spanner column label and the columns are those columns that belong in this group.

-

Here, weā€™ll put the mpg_c, mpg_h, hp, hp_rpm, trq, trq_rpm columns under the Performance spanner column, and the remaining columns wonā€™t be grouped together. This single spanner column label is styled with Markdown by using the md() helper.

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
yeartrimtrsmnPerformancemsrp
mpg_cmpg_hhphp_rpmtrqtrq_rpm
Germany
BMW i82016Mega World Coupe6am282935758004203700140700
Mercedes-Benz AMG GT2016S Coupe7a162250362504791750129900
Italy
Ferrari LaFerrari2015Base Coupe7a1216949900066467501416362
Lamborghini Aventador2015LP 700-4 Coupe7a111870082505075500397500
United States
Dodge Viper2017GT Coupe6m12196455000600500095895
Ford GT2017Base Coupe7a111864762505505900447000
Japan
Acura NSX2017Base Coupe9a212257365004762000156000
Nissan GT-R2016Premium Coupe6a162254564004363200101770
- -
-
-
-

-Merging Columns Together and Labeling Them

-

Sometimes weā€™d like to combine the data from two columns into a single column. The cols_merge() function allows us to do this, we just need to describe how the data should be combined. For our table, letā€™s merge together the following pairs of columns:

-
    -
  • -mpg_c and mpg_h (miles per gallon in city and highway driving modes)
  • -
  • -hp and hp_rpm (horsepower and associated RPM)
  • -
  • -trq and trq_rpm (torque and associated RPM)
  • -
-

The cols_merge() function uses a col_1 column and a col_2 column. Once combined, the col_1 column will be retained and the col_2 column will be dropped. The pattern argument uses {1} and {2} to represent the content of col_1 and col_2. Here, we can use string literals to add text like rpm or the @ sign. Furthermore, because we are targeting an HTML table, we can use the <br> tag to insert a linebreak.

-

Labeling columns essentially means that we are choosing display-friendly labels that are no longer simply the column names (the default label). The cols_label() function makes this relabeling possible. It accepts a series of named arguments in the form of <column_name> = <column_label>, ....

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
YearTrimTransmissionPerformanceMSRP
MPGHPTorque
Germany
BMW i82016Mega World Coupe6am28c
29h
357
@5800rpm
420
@3700rpm
140700
Mercedes-Benz AMG GT2016S Coupe7a16c
22h
503
@6250rpm
479
@1750rpm
129900
Italy
Ferrari LaFerrari2015Base Coupe7a12c
16h
949
@9000rpm
664
@6750rpm
1416362
Lamborghini Aventador2015LP 700-4 Coupe7a11c
18h
700
@8250rpm
507
@5500rpm
397500
United States
Dodge Viper2017GT Coupe6m12c
19h
645
@5000rpm
600
@5000rpm
95895
Ford GT2017Base Coupe7a11c
18h
647
@6250rpm
550
@5900rpm
447000
Japan
Acura NSX2017Base Coupe9a21c
22h
573
@6500rpm
476
@2000rpm
156000
Nissan GT-R2016Premium Coupe6a16c
22h
545
@6400rpm
436
@3200rpm
101770
- -
-
-
-

-Using Formatter Functions

-

There are a number of formatter functions, all with the general naming convention fmt*(). The various formatters are convenient for applying formats to numeric or character values in the tableā€™s field. Here, we will simply use fmt_currency() on the msrp column (we still refer to columns by their original names) to get USD currency will no decimal places. Weā€™re not supplying anything for the rows argument and this means we want to apply the formatting to the entire column of data.

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
YearTrimTransmissionPerformanceMSRP
MPGHPTorque
Germany
BMW i82016Mega World Coupe6am28c
29h
357
@5800rpm
420
@3700rpm
$140,700
Mercedes-Benz AMG GT2016S Coupe7a16c
22h
503
@6250rpm
479
@1750rpm
$129,900
Italy
Ferrari LaFerrari2015Base Coupe7a12c
16h
949
@9000rpm
664
@6750rpm
$1,416,362
Lamborghini Aventador2015LP 700-4 Coupe7a11c
18h
700
@8250rpm
507
@5500rpm
$397,500
United States
Dodge Viper2017GT Coupe6m12c
19h
645
@5000rpm
600
@5000rpm
$95,895
Ford GT2017Base Coupe7a11c
18h
647
@6250rpm
550
@5900rpm
$447,000
Japan
Acura NSX2017Base Coupe9a21c
22h
573
@6500rpm
476
@2000rpm
$156,000
Nissan GT-R2016Premium Coupe6a16c
22h
545
@6400rpm
436
@3200rpm
$101,770
- -
-
-
-

-Column Alignment and Style Changes

-

We can change the alignment of data in columns with cols_align(). For our table, letā€™s center-align the mpg_c, hp, and trq columns. All other columns will maintain their default alignments.

-

Itā€™s sometimes useful to modify the default styles of table cells. We can do this in a targeted way with the tab_style() function. That function require two key pieces of information: a style definition, and one or more locations (which cells should the styles be applied to?). The style argument commonly uses the cells_styles() helper function, which contains arguments for all the styles that are supported (use ?cells_styles for more information on this). Here we will use a text size of 12px in our targeted cellsā€”both px(12) and "12px" work equally well here. We also use helper functions with the locations argument and these are the cells_*() functions. We would like to target the data cells in all columns except year and msrp so we need to use cells_data and then supply our target columns to the columns argument.

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
YearTrimTransmissionPerformanceMSRP
MPGHPTorque
Germany
BMW i82016Mega World Coupe6am28c
29h
357
@5800rpm
420
@3700rpm
$140,700
Mercedes-Benz AMG GT2016S Coupe7a16c
22h
503
@6250rpm
479
@1750rpm
$129,900
Italy
Ferrari LaFerrari2015Base Coupe7a12c
16h
949
@9000rpm
664
@6750rpm
$1,416,362
Lamborghini Aventador2015LP 700-4 Coupe7a11c
18h
700
@8250rpm
507
@5500rpm
$397,500
United States
Dodge Viper2017GT Coupe6m12c
19h
645
@5000rpm
600
@5000rpm
$95,895
Ford GT2017Base Coupe7a11c
18h
647
@6250rpm
550
@5900rpm
$447,000
Japan
Acura NSX2017Base Coupe9a21c
22h
573
@6500rpm
476
@2000rpm
$156,000
Nissan GT-R2016Premium Coupe6a16c
22h
545
@6400rpm
436
@3200rpm
$101,770
- -
-
-
-

-Text Transforms

-

A text transform via the text_transform() function is a great way to further manipulate text in data cells (even after theyā€™ve been formatted with the fmt*() function). After targeting data cells with the cells_data() location helper function, we supply a function to the fn argument that processes a vector of text. If we intend to render as an HTML table, we can directly apply HTML tags in the transformation function. The function we provide here will build strings that read better in a display table.

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
YearTrimTransmissionPerformanceMSRP
MPGHPTorque
Germany
BMW i82016Mega World Coupe6 Speed
Automatic/Manual -
28c
29h
357
@5800rpm
420
@3700rpm
$140,700
Mercedes-Benz AMG GT2016S Coupe7 Speed
Automatic -
16c
22h
503
@6250rpm
479
@1750rpm
$129,900
Italy
Ferrari LaFerrari2015Base Coupe7 Speed
Automatic -
12c
16h
949
@9000rpm
664
@6750rpm
$1,416,362
Lamborghini Aventador2015LP 700-4 Coupe7 Speed
Automatic -
11c
18h
700
@8250rpm
507
@5500rpm
$397,500
United States
Dodge Viper2017GT Coupe6 Speed
Manual -
12c
19h
645
@5000rpm
600
@5000rpm
$95,895
Ford GT2017Base Coupe7 Speed
Automatic -
11c
18h
647
@6250rpm
550
@5900rpm
$447,000
Japan
Acura NSX2017Base Coupe9 Speed
Automatic -
21c
22h
573
@6500rpm
476
@2000rpm
$156,000
Nissan GT-R2016Premium Coupe6 Speed
Automatic -
16c
22h
545
@6400rpm
436
@3200rpm
$101,770
- -
-
-
-

-Table Header: Title and Subtitle

-

The tab_header() function allows us to place a table title and, optionally, a subtitle at the top of the display table. Itā€™s generally a good idea to have both in a table, where the subtitle provides additional information (though that isnā€™t quite the case in our example below).

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The Cars of gtcars -
These are some fine automobiles
YearTrimTransmissionPerformanceMSRP
MPGHPTorque
Germany
BMW i82016Mega World Coupe6 Speed
Automatic/Manual -
28c
29h
357
@5800rpm
420
@3700rpm
$140,700
Mercedes-Benz AMG GT2016S Coupe7 Speed
Automatic -
16c
22h
503
@6250rpm
479
@1750rpm
$129,900
Italy
Ferrari LaFerrari2015Base Coupe7 Speed
Automatic -
12c
16h
949
@9000rpm
664
@6750rpm
$1,416,362
Lamborghini Aventador2015LP 700-4 Coupe7 Speed
Automatic -
11c
18h
700
@8250rpm
507
@5500rpm
$397,500
United States
Dodge Viper2017GT Coupe6 Speed
Manual -
12c
19h
645
@5000rpm
600
@5000rpm
$95,895
Ford GT2017Base Coupe7 Speed
Automatic -
11c
18h
647
@6250rpm
550
@5900rpm
$447,000
Japan
Acura NSX2017Base Coupe9 Speed
Automatic -
21c
22h
573
@6500rpm
476
@2000rpm
$156,000
Nissan GT-R2016Premium Coupe6 Speed
Automatic -
16c
22h
545
@6400rpm
436
@3200rpm
$101,770
- -
-
-
-

-Adding a Source Citation

-

A source note can be added below the display table using the tab_source_note() function. We can even add multiple source notes with multiple calls of that function. Here, we supply a web URL and by using Markdown (with md()) itā€™s easy to create a link to the source of the data.

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The Cars of gtcars -
These are some fine automobiles
YearTrimTransmissionPerformanceMSRP
MPGHPTorque
Germany
BMW i82016Mega World Coupe6 Speed
Automatic/Manual -
28c
29h
357
@5800rpm
420
@3700rpm
$140,700
Mercedes-Benz AMG GT2016S Coupe7 Speed
Automatic -
16c
22h
503
@6250rpm
479
@1750rpm
$129,900
Italy
Ferrari LaFerrari2015Base Coupe7 Speed
Automatic -
12c
16h
949
@9000rpm
664
@6750rpm
$1,416,362
Lamborghini Aventador2015LP 700-4 Coupe7 Speed
Automatic -
11c
18h
700
@8250rpm
507
@5500rpm
$397,500
United States
Dodge Viper2017GT Coupe6 Speed
Manual -
12c
19h
645
@5000rpm
600
@5000rpm
$95,895
Ford GT2017Base Coupe7 Speed
Automatic -
11c
18h
647
@6250rpm
550
@5900rpm
$447,000
Japan
Acura NSX2017Base Coupe9 Speed
Automatic -
21c
22h
573
@6500rpm
476
@2000rpm
$156,000
Nissan GT-R2016Premium Coupe6 Speed
Automatic -
16c
22h
545
@6400rpm
436
@3200rpm
$101,770
Source: Various pages within edmunds.com.
- -
-
-
-

-Using the Complete gtcars table and Adding Footnotes

-

Letā€™s bring it all together by putting together all the statements we developed for gtcars_8, and applying that to the complete gtcars dataset. At the same time, weā€™ll add a few interesting footnotes and our specific requirements for footnoting are:

-
a. identifying the car with the best gas mileage (city)
-b. identifying the car with the highest horsepower
-c. stating the currency of the MSRP
-

The tab_footnote() function expects note text for the footnote argument, and locations for where the glyph should be attached. It will handle the placement of the note glyph and also place the footnote in the footnotes area. Here, weā€™ll use the cells_data() location helper function. There are several location helper functions for targeting all parts of the table (e.g,. cells_data(), cells_stub(), etc.). Each location helper has their own interface for targeting cells, help is available at ?gt::location_cells.

-

What cells_data() expects is columns (column names, which can be conveniently provided in vars()) and rows (which can be a vector of row names or row indices). The cells_stub() location helper only expects a vector of rows. For cells_column_labels(), we can either provided targeted column labels in the columns argument or spanner column labels in the groups argument. Here, we are targeting a footnote to the msrp column label so we will use columns = vars(msrp).

-

In terms of structuring the code, weā€™re taking all the previous statements and putting those in first. It should be noted that the order of the statements does not matter to the end result, we could also put in all of the tab_footnote() statements first (again, any in order) and expect the same output table.

-

-# Use dplyr functions to get the car with the best city gas mileage;
-# this will be used to target the correct cell for a footnote
-best_gas_mileage_city <- 
-  gtcars %>% 
-  dplyr::arrange(desc(mpg_c)) %>%
-  dplyr::slice(1) %>%
-  dplyr::mutate(car = paste(mfr, model)) %>%
-  dplyr::pull(car)
-
-# Use dplyr functions to get the car with the highest horsepower
-# this will be used to target the correct cell for a footnote
-highest_horsepower <- 
-  gtcars %>% 
-  dplyr::arrange(desc(hp)) %>%
-  dplyr::slice(1) %>%
-  dplyr::mutate(car = paste(mfr, model)) %>%
-  dplyr::pull(car)
-
-# Create a display table with `gtcars`, using all of the previous
-# statements piped together + additional `tab_footnote()` stmts
-tab <-
-  gtcars %>%
-  dplyr::arrange(
-    factor(ctry_origin, levels = order_countries),
-    mfr, desc(msrp)
-  ) %>%
-  dplyr::mutate(car = paste(mfr, model)) %>%
-  dplyr::select(-mfr, -model) %>%
-  dplyr::group_by(ctry_origin) %>%
-  gt(rowname_col = "car") %>%
-  cols_hide(columns = vars(drivetrain, bdy_style)) %>%
-  cols_move(
-    columns = vars(trsmn, mpg_c, mpg_h),
-    after = vars(trim)
-  ) %>%
-  tab_spanner(
-    label = md("*Performance*"),
-    columns = vars(mpg_c, mpg_h, hp, hp_rpm, trq, trq_rpm)
-  ) %>%
-  cols_merge(
-    col_1 = vars(mpg_c),
-    col_2 = vars(mpg_h),
-    pattern = "{1}c<br>{2}h"
-  ) %>%
-  cols_merge(
-    col_1 = vars(hp),
-    col_2 = vars(hp_rpm),
-    pattern = "{1}<br>@{2}rpm"
-  ) %>%
-  cols_merge(
-    col_1 = vars(trq),
-    col_2 = vars(trq_rpm),
-    pattern = "{1}<br>@{2}rpm"
-  ) %>%
-  cols_label(
-    mpg_c = "MPG",
-    hp = "HP",
-    trq = "Torque",
-    year = "Year",
-    trim = "Trim",
-    trsmn = "Transmission",
-    msrp = "MSRP"
-  ) %>%
-  fmt_currency(
-    columns = vars(msrp),
-    currency = "USD",
-    decimals = 0
-  ) %>%
-  cols_align(
-    align = "center",
-    columns = vars(mpg_c, hp, trq)
-  ) %>%
-  tab_style(
-    style = cells_styles(text_size = px(12)),
-    locations = cells_data(columns = vars(trim, trsmn, mpg_c, hp, trq))
-  ) %>%
-  text_transform(
-    locations = cells_data(columns = vars(trsmn)),
-    fn = function(x) {
-      
-      speed <- substr(x, 1, 1)
-      
-      type <-
-        dplyr::case_when(
-          substr(x, 2, 3) == "am" ~ "Automatic/Manual",
-          substr(x, 2, 2) == "m" ~ "Manual",
-          substr(x, 2, 2) == "a" ~ "Automatic",
-          substr(x, 2, 3) == "dd" ~ "Direct Drive"
-        )
-      
-      paste(speed, " Speed<br><em>", type, "</em>")
-    }
-  ) %>%
-  tab_header(
-    title = md("The Cars of **gtcars**"),
-    subtitle = "These are some fine automobiles"
-  ) %>%
-  tab_source_note(
-    source_note = md(
-      "Source: Various pages within [edmunds.com](https://www.edmunds.com).")
-  ) %>%
-  tab_footnote(
-    footnote = md("Best gas mileage (city) of all the **gtcars**."),
-    locations = cells_data(
-      columns = vars(mpg_c),
-      rows = best_gas_mileage_city)
-  ) %>%
-  tab_footnote(
-    footnote = md("The highest horsepower of all the **gtcars**."),
-    locations = cells_data(
-      columns = vars(hp),
-      rows = highest_horsepower)
-  ) %>%
-  tab_footnote(
-    footnote = "All prices in U.S. dollars (USD).",
-    locations = cells_column_labels(
-      columns = vars(msrp))
-  )
-
-# Show the table
-tab
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The Cars of gtcars -
These are some fine automobiles
YearTrimTransmissionPerformanceMSRP1 -
MPGHPTorque
Germany
Audi R820154.2 (Manual) Coupe6 Speed
Manual -
11c
20h
430
@7900rpm
317
@4500rpm
$115,900
Audi S82016Base Sedan8 Speed
Automatic/Manual -
15c
25h
520
@5800rpm
481
@1700rpm
$114,900
Audi RS 72016Quattro Hatchback8 Speed
Automatic/Manual -
15c
25h
560
@5700rpm
516
@1750rpm
$108,900
Audi S72016Prestige quattro Hatchback7 Speed
Automatic -
17c
27h
450
@5800rpm
406
@1400rpm
$82,900
Audi S62016Premium Plus quattro Sedan7 Speed
Automatic -
18c
27h
450
@5800rpm
406
@1400rpm
$70,900
BMW i82016Mega World Coupe6 Speed
Automatic/Manual -
28c
29h2 -
357
@5800rpm
420
@3700rpm
$140,700
BMW M62016Base Coupe7 Speed
Automatic -
15c
22h
560
@6000rpm
500
@1500rpm
$113,400
BMW M52016Base Sedan7 Speed
Automatic/Manual -
15c
22h
560
@6000rpm
500
@1500rpm
$94,100
BMW 6-Series2016640 I Coupe8 Speed
Automatic/Manual -
20c
30h
315
@5800rpm
330
@1400rpm
$77,300
BMW M42016Base Coupe6 Speed
Manual -
17c
24h
425
@5500rpm
406
@1850rpm
$65,700
Mercedes-Benz AMG GT2016S Coupe7 Speed
Automatic -
16c
22h
503
@6250rpm
479
@1750rpm
$129,900
Mercedes-Benz SL-Class2016SL400 Convertible7 Speed
Automatic/Manual -
20c
27h
329
@5250rpm
354
@1600rpm
$85,050
Porsche 9112016Carrera Coupe7 Speed
Manual -
20c
28h
350
@7400rpm
287
@5600rpm
$84,300
Porsche Panamera2016Base Sedan7 Speed
Automatic -
18c
28h
310
@6200rpm
295
@3750rpm
$78,100
Porsche 718 Boxster2017Base Convertible6 Speed
Manual -
21c
28h
300
@6500rpm
280
@1950rpm
$56,000
Porsche 718 Cayman2017Base Coupe6 Speed
Manual -
20c
29h
300
@6500rpm
280
@1950rpm
$53,900
Italy
Ferrari LaFerrari2015Base Coupe7 Speed
Automatic -
12c
16h
949
@9000rpm3 -
664
@6750rpm
$1,416,362
Ferrari F12Berlinetta2015Base Coupe7 Speed
Automatic -
11c
16h
731
@8250rpm
509
@6000rpm
$319,995
Ferrari GTC4Lusso2017Base Coupe7 Speed
Automatic -
12c
17h
680
@8250rpm
514
@5750rpm
$298,000
Ferrari FF2015Base Coupe7 Speed
Automatic -
11c
16h
652
@8000rpm
504
@6000rpm
$295,000
Ferrari 458 Speciale2015Base Coupe7 Speed
Automatic -
13c
17h
597
@9000rpm
398
@6000rpm
$291,744
Ferrari 458 Spider2015Base7 Speed
Automatic -
13c
17h
562
@9000rpm
398
@6000rpm
$263,553
Ferrari 488 GTB2016Base Coupe7 Speed
Automatic -
15c
22h
661
@8000rpm
561
@3000rpm
$245,400
Ferrari 458 Italia2014Base Coupe7 Speed
Automatic -
13c
17h
562
@9000rpm
398
@6000rpm
$233,509
Ferrari California2015Base Convertible7 Speed
Automatic -
16c
23h
553
@7500rpm
557
@4750rpm
$198,973
Lamborghini Aventador2015LP 700-4 Coupe7 Speed
Automatic -
11c
18h
700
@8250rpm
507
@5500rpm
$397,500
Lamborghini Huracan2015LP 610-4 Coupe7 Speed
Automatic -
16c
20h
610
@8250rpm
413
@6500rpm
$237,250
Lamborghini Gallardo2014LP 550-2 Coupe6 Speed
Automatic -
12c
20h
550
@8000rpm
398
@6500rpm
$191,900
Maserati Granturismo2016Sport Coupe6 Speed
Automatic/Manual -
13c
21h
454
@7600rpm
384
@4750rpm
$132,825
Maserati Quattroporte2016S Sedan8 Speed
Automatic/Manual -
16c
23h
404
@5500rpm
406
@1500rpm
$99,900
Maserati Ghibli2016Base Sedan8 Speed
Automatic/Manual -
17c
24h
345
@5250rpm
369
@1750rpm
$70,600
United States
Chevrolet Corvette2016Z06 Coupe7 Speed
Manual -
15c
22h
650
@6400rpm
650
@3600rpm
$88,345
Dodge Viper2017GT Coupe6 Speed
Manual -
12c
19h
645
@5000rpm
600
@5000rpm
$95,895
Ford GT2017Base Coupe7 Speed
Automatic -
11c
18h
647
@6250rpm
550
@5900rpm
$447,000
Tesla Model S201775D1 Speed
Direct Drive -
NA259
@6100rpm
243$74,500
Japan
Acura NSX2017Base Coupe9 Speed
Automatic -
21c
22h
573
@6500rpm
476
@2000rpm
$156,000
Nissan GT-R2016Premium Coupe6 Speed
Automatic -
16c
22h
545
@6400rpm
436
@3200rpm
$101,770
United Kingdom
Aston Martin Vanquish2016Base Coupe8 Speed
Automatic/Manual -
13c
21h
568
@6650rpm
465
@5500rpm
$287,250
Aston Martin DB112017Base Coupe8 Speed
Automatic/Manual -
15c
21h
608
@6500rpm
516
@1500rpm
$211,195
Aston Martin Rapide S2016Base Sedan8 Speed
Automatic/Manual -
14c
21h
552
@6650rpm
465
@5500rpm
$205,300
Aston Martin Vantage2016V8 GT (Manual) Coupe6 Speed
Manual -
13c
19h
430
@7300rpm
361
@5000rpm
$103,300
Bentley Continental GT2016V8 Coupe8 Speed
Automatic/Manual -
15c
25h
500
@6000rpm
487
@1700rpm
$198,500
Jaguar F-Type2016Base (Manual) Coupe6 Speed
Manual -
16c
24h
340
@6500rpm
332
@3500rpm
$65,000
Lotus Evora20172+2 Coupe6 Speed
Manual -
16c
24h
400
@7000rpm
302
@3500rpm
$91,900
McLaren 5702016Base Coupe7 Speed
Automatic -
16c
23h
570
@7500rpm
443
@5000rpm
$184,900
Rolls-Royce Dawn2016Base Convertible8 Speed
Automatic -
12c
19h
563
@5250rpm
575
@1500rpm
$335,000
Rolls-Royce Wraith2016Base Coupe8 Speed
Automatic -
13c
21h
624
@5600rpm
590
@1500rpm
$304,350
Source: Various pages within edmunds.com.
-1 All prices in U.S. dollars (USD).
2 Best gas mileage (city) of all the gtcars.
3 The highest horsepower of all the gtcars.
- -
-

That is it. The final table looks pretty good and conveys the additional information we planned for. That table can be used in a lot of different places like R Markdown, Shiny, email messagesā€¦ wherever HTML is accepted.

-
-
- - - -
- - - -
- - - - - diff --git a/docs/articles/creating-display-tables.html b/docs/articles/creating-display-tables.html deleted file mode 100644 index 5a2199124d..0000000000 --- a/docs/articles/creating-display-tables.html +++ /dev/null @@ -1,4062 +0,0 @@ - - - - - - - -Introduction to Creating gt Tables ā€¢ gt - - - - - - - - - -
-
- - - -
-
- - - - -

The gt package is all about making it simple to produce nice-looking display tables. Display tables? Well yes, we are trying to distinguish between data tables (e.g., tibbles, data.frames, etc.) and those tables youā€™d find in a web page, a journal article, or in a magazine. Such tables can likewise be called presentation tables, summary tables, or just tables really. Here are some examples, ripped straight from the web:

-

-

We can think of display tables as output only, where weā€™d not want to use them as input ever again. Other features include annotations, table element styling, and text transformations that serve to communicate the subject matter more clearly.

-
-

-A Walkthrough of the gt Basics with a Simple Table

-

Letā€™s use a less common dataset that is available in the R datasets package: islands. Itā€™s actually not a data frame but a named vector. Thatā€™s okay though, we can use use dplyr and prepare a tibble from it:

- -

Given that islands_tbl is a tibble, we now have a suitable input for gt.

-

The main entry point into the gt API is the gt() function. If we pass islands_tbl to the function gt(), weā€™ll get a gt Table as output. As an aside, we could have easily used a data frame instead as valid Table Data for gt.

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
namesize
Asia16988
Africa11506
North America9390
South America6795
Antarctica5500
Europe3745
Australia2968
Greenland840
New Guinea306
Borneo280
- -
-

That doesnā€™t look too bad. Sure, itā€™s basic but we really didnā€™t really ask for much. We did receive a proper table with column labels and the data. Also, that default striping is a nice touch. Oftentimes however, youā€™ll want a bit more: a Table header, a Stub, and sometimes footnotes and source notes in the Table Footer part.

-
-
-

-Adding Parts to this Simple Table

-

The gt package makes it relatively easy to add parts so that the resulting gt Table better conveys the information you want to present. These table parts work well together and there the possible variations in arrangement can handle most tabular presentation needs. The previous gt Table demonstrated had only two parts, the Column Labels and the Table Body. The next few examples will show all of the other table parts that are available.

-

This is the way the main parts of a table (and their subparts) fit together:

-

-

-

The parts (roughly from top to bottom) are:

-
    -
  • the Table Header (optional; with a title and possibly a subtitle)
  • -
  • the Stub and the Stub Head (optional; contains row labels, optionally within row groups having row group labels and possibly summary labels when a summary is present)
  • -
  • the Column Labels (contains column labels, optionally under spanner column labels)
  • -
  • the Table Body (contains columns and rows of cells)
  • -
  • the Table Footer (optional; possibly with footnotes and source notes)
  • -
-

The way that we add parts like the Table Header and footnotes in the Table Footer is to use the tab_*() family of functions. A Table Header is easy to add so letā€™s see how the previous table looks with a title and a subtitle. We can add this part using the tab_header() function:

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Large Landmasses of the World
The top ten largest are presented
namesize
Asia16988
Africa11506
North America9390
South America6795
Antarctica5500
Europe3745
Australia2968
Greenland840
New Guinea306
Borneo280
- -
-

The Header table part provides an opportunity to describe the data thatā€™s presented. The subtitle, which functions as a subtitle, is an optional part of the Header. We may also style the title and subtitle using Markdown! We do this by wrapping the values passed to title or subtitle with the md() function. Here is an example with the table data truncated for brevity:

-
# Use markdown for the heading's `title` and `subtitle` to
-# add bold and italicized characters
-gt(islands_tbl[1:2,]) %>%
-  tab_header(
-    title = md("**Large Landmasses of the World**"),
-    subtitle = md("The *top two* largest are presented")
-  )
- -
- - - - - - - - - - - - - - - - - - - - - - - - -
Large Landmasses of the World
The top two largest are presented
namesize
Asia16988
Africa11506
- -
-

A source note can be added to the tableā€™s footer through use of the tab_source_note() function. It works in the same way as tab_header() (it also allows for Markdown inputs) except it can be called multiple timesā€”each invocation results in the addition of a source note.

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Large Landmasses of the World
The top ten largest are presented
namesize
Asia16988
Africa11506
North America9390
South America6795
Antarctica5500
Europe3745
Australia2968
Greenland840
New Guinea306
Borneo280
Source: The World Almanac and Book of Facts, 1975, page 406.
Reference: McNeil, D. R. (1977) Interactive Data Analysis. Wiley.
- -
-

Footnotes live inside the Footer part and their reference glyphs are attached to cell data. Footnotes are added with the tab_footnote() function. The helper function cells_data() can be used with the location argument to specify which data cells should be the target of the footnote. The cells_data() helper has the two arguments columns and rows. For each of these, we can supply (1) a vector of colnames or rownames, (2) a vector of column/row indices, (3) bare column names wrapped in vars() or row labels within c(), or (4) a select helper function (starts_with(), ends_with(), contains(), matches(), one_of(), and everything()). For rows specifically, we can use a conditional statement with column names as variables (e.g., size > 15000).

-

Here is a simple example on how a footnotes can be added to a table cell. Letā€™s add a footnote that references the North America and South America cells in the name column:

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Large Landmasses of the World
The top ten largest are presented
namesize
Asia16988
Africa11506
North America1 -9390
South America1 -6795
Antarctica5500
Europe3745
Australia2968
Greenland840
New Guinea306
Borneo280
Source: The World Almanac and Book of Facts, 1975, page 406.
Reference: McNeil, D. R. (1977) Interactive Data Analysis. Wiley.
-1 The Americas.
- -
-

Here is a slightly more complex example of adding footnotes that use expressions in rows to help target cells in a column by the underlying data in islands_tbl. First, a set of dplyr statements obtains the name of the ā€˜islandā€™ by largest landmass. This is assigned to the largest object and is used in the first tab_footnote() call that targets the cell in the size column that is next to a name value that is stored in largest (ā€™Asiaā€™). The second tab_footnote() is similar except we are supplying a conditional statement that gets the lowest population.

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Large Landmasses of the World
The top ten largest are presented
namesize
Asia169881 -
Africa11506
North America2 -9390
South America2 -6795
Antarctica5500
Europe3745
Australia2968
Greenland840
New Guinea306
Borneo2803 -
Source: The World Almanac and Book of Facts, 1975, page 406.
Reference: McNeil, D. R. (1977) Interactive Data Analysis. Wiley.
-1 The largest by area.
2 The Americas.
3 The lowest by population.
- -
-

We were able to supply the reference locations in the table by using the cells_data() helper function and supplying the necessary targeting through the columns and rows arguments. Other cells_*() functions have similar interfaces and they allow us to target cells in different parts of the table.

-
-
-

-The Stub

-

The Stub is the area to the left in a table that contains row labels, and may contain row group labels, and summary labels. Those subparts can be grouped in a sequence of row groups. The Stub Head provides a location for a label that describes the Stub. The Stub is optional since there are cases where a Stub wouldnā€™t be useful (e.g., the display tables presented above were just fine without a Stub).

-

An easy way to generate a Stub part is by specifying a stub column in the gt() function with the rowname_col argument. Alternatively, we can have an input dataset with a column named rownameā€”this magic column will signal to gt that that column should be used as the stub, making row labels. Letā€™s add a stub with our islands_tbl dataset by modifying the call to gt():

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
size
Asia16988
Africa11506
North America9390
South America6795
Antarctica5500
Europe3745
Australia2968
Greenland840
New Guinea306
Borneo280
- -
-

Notice that the landmass names are off the the left in an unstriped area? Thatā€™s the stub. We can apply whatā€™s known as a stubhead label. This label can be added with the tab_stubhead_label() function:

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
landmasssize
Asia16988
Africa11506
North America9390
South America6795
Antarctica5500
Europe3745
Australia2968
Greenland840
New Guinea306
Borneo280
- -
-

A very important thing to note here is that the table now has one column. Before, when there was no stub, two columns were present (with column labels name and size) but now column number 1 (the only column) is size.

-

To apply our table parts as before (up to and including the footnotes) we use the following statements:

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Large Landmasses of the World
The top ten largest are presented
landmasssize
Asia169881 -
Africa11506
North America9390
South America6795
Antarctica55002 -
Europe3745
Australia2968
Greenland840
New Guinea306
Borneo280
Source: The World Almanac and Book of Facts, 1975, page 406.
Reference: McNeil, D. R. (1977) Interactive Data Analysis. Wiley.
-1 The largest by area.
2 The lowest by population.
- -
-

Letā€™s incorporate row groups into the display table. This divides rows into groups, creating row groups, and results in a display of a row group labels right above the each group. This can be easily done with a table containing row labels. We can make a new row group with each call of the tab_row_group() function. The inputs are group names in the group argument, and row references in the rows argument. We can use any of the strategies to reference rows as we did we footnotes (e.g., vectors of names/indices, select helpers, etc.).

-

Here we will create three row groups (with row group labels continent, country, and subregion) to have a grouping of rows.

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Large Landmasses of the World
The top ten largest are presented
landmasssize
continent
Asia169881 -
Africa11506
North America9390
South America6795
Antarctica55002 -
Europe3745
country
Australia2968
Greenland840
subregion
New Guinea306
Borneo280
Source: The World Almanac and Book of Facts, 1975, page 406.
Reference: McNeil, D. R. (1977) Interactive Data Analysis. Wiley.
-1 The largest by area.
2 The lowest by population.
- -
-

Three row groups have been made since there are three unique categories under groupname. Across the top of each row group is the row group label contained in a separate row (these cut across the field and they contain nothing but the row group label). A rearrangement of rows is carried out to ensure each of the rows is collected within the appropriate row groups.

-

Having groups of rows in row groups is a great way to present information. Including data summaries particular to each group is a natural extension of this idea. This process of adding summary rows with summary labels is covered in a separate article (Creating Summary Lines).

-

Another way to make row groups is to have the magic column groupname present in the input data table. For our above example with islands_tbl, a groupname column with the categories continent, country, and subregion in the appropriate rows would produce row groups automatically (i.e., there would be no need to use the tab_row_group() statements). This strategy of supplying group names in a groupname column name can sometimes be advantageous since we can rely on functions such as those available in dplyr to generate the categories (e.g., using case_when() or if_else()).

-
-
-

-The Column Labels

-

The tableā€™s Column Labels part contains, at a minimum, columns and their column labels. The last example had a single column: size. Just as in the Stub, we can create groupings called spanner columns that encompass one or more columns.

-

To better demonstrate how Column Labels work and are displayed, letā€™s use an input data table with more columns. In this case, that input table will be airquality. It has the following columns:

-
    -
  • -Ozone: mean ground-level ozone in parts per billion by volume (ppbV), measured between 13:00 and 15:00
  • -
  • -Solar.R: solar radiation in Langley units (cal/m2), measured between 08:00 and noon
  • -
  • -Wind: mean wind speed in miles per hour (mph)
  • -
  • -Temp: maximum daily air temperature in degrees Fahrenheit (Ā°F)
  • -
  • -Month, Day: the numeric month and day of month for the record
  • -
-

We know that all measurements took place in 1973, so a year column will be added to the dataset before it is passed to gt().

-

Letā€™s organize the time information under a Time spanner column label, and put the other columns under a Measurement spanner column label. We can do this with the tab_spanner() function.

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New York Air Quality Measurements
Daily measurements in New York City (May 1-10, 1973)
MeasurementTime
OzoneSolar.RWindTempMonthDayYear
411907.467511973
361188.072521973
1214912.674531973
1831311.562541973
NANA14.356551973
28NA14.966561973
232998.665571973
199913.859581973
81920.161591973
NA1948.6695101973
- -
-

We can do two more things to make this presentable:

-
    -
  • move the Time columns to the beginning of the series (using cols_move_to_start())
  • -
  • customize the column labels so that they are more descriptive (using cols_label())
  • -
-

Letā€™s do both of these things in the next example.

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New York Air Quality Measurements
Daily measurements in New York City (May 1-10, 1973)
TimeMeasurement
YearMonthDayOzone,
ppbV
Solar R.,
cal/m2 -
Wind,
mph
Temp,
Ā°F
197351411907.467
197352361188.072
1973531214912.674
1973541831311.562
197355NANA14.356
19735628NA14.966
197357232998.665
197358199913.859
19735981920.161
1973510NA1948.669
- -
-

Note that even though columns were moved using cols_move_to_start(), the spanner column labels still spanned above the correct column labels. There are a number of functions that gt provides to move columns, including cols_move(), cols_move_to_end(); thereā€™s even a function to hide columns: cols_hide().

-

Multiple columns can be renamed in a single use of cols_label(). Further to this, the helper functions md() and html() can be used to create column labels with additional styling. In the above example, we provided column labels as HTML so that we can insert linebreaks with <br>, insert a superscripted 2 (with <sup>2</sup>), and insert a degree symbol as an HTML entity (&deg;).

-
-
- - - -
- - - -
- - - - - diff --git a/docs/articles/creating-summary-lines.html b/docs/articles/creating-summary-lines.html deleted file mode 100644 index c6d0427d01..0000000000 --- a/docs/articles/creating-summary-lines.html +++ /dev/null @@ -1,3385 +0,0 @@ - - - - - - - -Creating Summary Lines ā€¢ gt - - - - - - - - - - - - - - - - -
-
- - - -
-
- - - - -

Tables with summary data are quite common and naturally occur with alarming regularity. We can use gt to produce such summary components. These summary rows are automatically inserted within the relevant row groups, where each summary row is the result of a different aggregation function.

-
-

-Preparing the Input Data Table

-

To most easily insert the necessary summary rows, we need to ensure that some preparatory work is done. The key change to the input data table should be to have a groupname column present, with categorical group names for each grouping. The following example data table contains both groupname and rowname columns, along with two data columns (named value_1 and value_2). Having the magic column names groupname and rowname will signal to gt that they should be used to form a table stub where groupname collects rows into a row group (furnishing a group heading row above), and rowname provides row labels within each row group. Here is a diagram showing the restructuring:

-

The incoming data table for the purpose of the first example will be created using dplyr::tribble():

- -

There are three groups in this data table: A, B, and C. The presence of the groupname column will tell gt to partition the stub into three row groups. This is how the gt display table appears after simply providing tbl to gt():

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
value_1value_2
A
1235.6260.1
2184.384.4
3342.3126.3
4234.983.0
B
1190.9832.5
2743.3281.2
3252.3732.5
4344.7546.1
C
1197.2818.0
2284.3394.4
- -
-
-
-

-Generating Summary Rows

-

Summaries by row group can be generated by using the summary_rows() function. Thereā€™s a lot of control in how the summaries are conducted and formatted. First of all, we can choose which groups will receive summary rows (the rows appear at the bottom of each row group). This optional choice of groups can be made using the groups argument (providing a vector of group names). Secondly, we can choose which columns should be included in the summary with the columns argument (in this case, wrapping column names in vars()). If we provide nothing to groups, then all groups will receive summary data for the selected columns.

-

To make any sort of summary, we need to use functions that will perform the aggregation. We can provide base functions such as mean(), sum(), min(), max(), and more, within a list() or c(). Each function provided will result in a summary row for each group.

-

Because each function will yield a row, we need to be able to identify that row. So, each summary row will receive a summary row label. We can provide our preferred names by naming the functions within the list or c() (e.g, list(average = "mean", total = "sum", SD = "sd") or c("mean", total = "sum", stdev = "sd")). If names arenā€™t supplied, then gt will derive names from the functions supplied and make the names unique.

-

Now that the summary_rows() function has been somewhat explained, letā€™s look at how we can get summary rows for the tbl table:

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
value_1value_2
A
1235.6260.1
2184.384.4
3342.3126.3
4234.983.0
mean249.28ā€”
sum997.10ā€”
sd66.51ā€”
B
1190.9832.5
2743.3281.2
3252.3732.5
4344.7546.1
mean382.80ā€”
sum1,531.20ā€”
sd248.51ā€”
C
1197.2818.0
2284.3394.4
- -
-

Here we see that summary rows were created for the A and B groups (group C has no summary lines in its row group). It was specified in columns that only the value_1 column should be evaluated and, indeed, the value_2 column shows no values whatsoever within the summary rows.

-

There is some flexibility in how we supply aggregation functions to summary_rows(). Itā€™s sometimes sufficient to supply function names enclosed in quotes (e.g., list("mean", "sum", "sd")) but the next section will demonstrate a more advanced method for supplying these functions (where we donā€™t have to rely on function defaults). If we already have a vector of function names that use all of the default arguments within those functions, we can pass this directly to fns. This is nice if we want to build a common named vector of function names and summary labels. Hereā€™s an example that does just that:

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
value_1value_2
A
1235.6260.1
2184.384.4
3342.3126.3
4234.983.0
average249.28ā€”
total997.10ā€”
std dev66.51ā€”
B
1190.9832.5
2743.3281.2
3252.3732.5
4344.7546.1
average382.80ā€”
total1,531.20ā€”
std dev248.51ā€”
C
1197.2818.0
2284.3394.4
average240.75ā€”
total481.50ā€”
std dev61.59ā€”
- -
-
-
-

-Providing Calls to Functions with a Formula Interface

-

Sometimes we want to use functions with some parameters set. The earlier example using list("mean", "sum", "sd") will break down if we have NA values in our data and we want to exclude those by using na.rm = TRUE. In this case we can provide a call to a function with a right-hand side (RHS) formula shortcut, having . serve as the data values. Here is an example where we modify our tbl to include some NA values (calling it tbl_na) and then changing the contents of the list()ā€”using c() will work just as wellā€”as calls to functions:

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
value_1value_2
A
1235.6260.1
2184.384.4
3NA126.3
4234.983.0
average218.27138.45
sum654.80553.80
std dev29.4283.55
B
1190.9NA
2NA281.2
3252.3NA
4NA546.1
average221.60413.65
sum443.20827.30
std dev43.42187.31
C
1197.2NA
2284.3394.4
- -
-

The input to fns is very permissive in regard to how the functions are defined. It is entirely valid to provide functions in the various forms shown earlier such that list("sum", ~mean(., na.rm = TRUE), SD = "sd") will be correctly interpreted.

-
-
-

-Formatting the Summary Output Values

-

Using summary_rows() to generate a summary is, in effect, creating new data and thus we need some means to format the new summary row data. We can use the formatter option to supply a formatting function to handle the formatting of the summary row data. Thankfully, we have a collection of formatting functions available in the package (i.e., all of the fmt_*() functions). The default for formatter is set to fmt_number which is a sensible default for many scenarios. The setting of argument values for a particular formatter can be done in the ... area of the function call.

-

Letā€™s start with an example where we format the summary row data using fmt_number as the formatter. The fmt_number() function several arguments to which we can pass values (decimals, drop_trailing_zeros, negative_val, locale, etc.). Here, we will provide decimals = 3 to augment fmt_number():

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
value_1value_2
A
1235.6260.1
2184.384.4
3342.3126.3
4234.983.0
mean249.275138.450
sum997.100553.800
min184.30083.000
max342.300260.100
B
1190.9832.5
2743.3281.2
3252.3732.5
4344.7546.1
C
1197.2818.0
2284.3394.4
- -
-

We can also store these argument values as local variables and pass them in both separate fmt_number() calls and then to a summary_rows() calls with fmt_number() used as the formatter. This is useful for standardizing formatting parameters across different table cell types.

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
value_1value_2
A
1235,60260,10
2184,3084,40
3342,30126,30
4234,9083,00
mean249,28138,45
sum997,10553,80
min184,3083,00
max342,30260,10
B
1190,90832,50
2743,30281,20
3252,30732,50
4344,70546,10
C
1197,20818,00
2284,30394,40
- -
-
-
-

-Extracting the Summary Data from the gt Table Object

-

For a reproducible workflow, we do not want to have situations where any data created or modified cannot be accessed. While having summarized values be created in a gt pipeline presents advantages to readability and intent of analysis, it is recognized that the output table itself is essentially ā€˜read onlyā€™, as the input data undergoes processing and movement to an entirely different format.

-

However, the object created still contains data and we can obtain the summary data from a gt table object using the extract_summary() function. Taking the gt_summary object, we get a data frame containing the summary data while preserving the correct data types:

- - - - -

The output data frames within the list always contain the groupname and rowname columns. The groupname column is filled with the name of the stub group given in summary_rows(). The rowname column contains the descriptive stub labels for the summary rows (recall that values are either supplied explicitly in summary_rows(), or, are generated from the function names). The remaining columns are from the original dataset.

-

The output data frame from extract_summary() can be reintroduced to a reproducible workflow and serve as downstream inputs or undergo validation. Perhaps interestingly, the output data frame is structured in a way that facilitates direct input to gt() (i.e., has the magic groupname and rowname columns). This can produce a new, standalone summary table where the summary rows are now data rows:

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
value_1value_2
A
mean249.275138.450
sum997.100553.800
sd66.50683.551
B
mean382.800598.075
sum1,531.2002,392.300
sd248.507242.306
- -
-
-
-

-Providing Our Own Aggregation Functions to Generate Summary Rows

-

While many of the functions available in base R and within packages are useful as aggregate functions, we may occasionally have need to create our own custom functions. The only things to keep in mind are to ensure that a vector of values is the main input, and, a single value is returned. The return value can be most any class (e.g., numeric, character, logical) and itā€™s the formatter function that will handle any custom formatting while also converting to character.

-

Here, weā€™ll define a function that takes a vector of numeric values and outputs the two highest values (sorted low to high) above a threshold value. The output from this function is always a formatted character string.

- -

Because this is character value thatā€™s returned, we donā€™t need formatting functions like fmt_number(), fmt_percent(), etc. However, a useful formatter (and we do need some formatter) is the fmt_passthrough() function. Like the name suggests, it to great extent passes values through but formats as character (like all the fmt_*() function do) and it provides the option to decorate the output with a pattern. Letā€™s have a look at how the agg_highest_two_above_value() function can be used with the fmt_passthrough() formatter function.

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
value_1value_2
A
1235.6260.1
2184.384.4
3ā€”126.3
4234.983
high(234.90, 235.60)(260.10)
B
1190.9ā€”
2ā€”281.2
3252.3ā€”
4ā€”546.1
high(190.90, 252.30)(281.20, 546.10)
C
1197.2ā€”
2284.3394.4
high(197.20, 284.30)(394.40)
- -
-

We can extract the summary data from the summary_tbl object. Note that columns value_1 and value_2 are classed as character since it was character outputs that were generated by the agg_highest_two_above_value() function.

- -
-
-

-Using Different Formatters for Different Columns

-

Suppose we have data across columns that should be summarized in the same way (i.e., common aggregate functions) but formatted differently (e.g., decimal notation, scientific notation, percentages, etc.). For each type of formatting, we need to call summary_rows(), however, we can employ certain strategies to make the code a bit more succinct while doing so.

-

Letā€™s start with a new data table. This table contains groupname and rowname columns, which making using summary_rows() possible, along with large, medium, and small data columns, all containing numeric values.

- -

Here, we would like to apply a different format (both to the data rows and to the summary rows) across the three columns. We can store formatting options to three different list objects (large_fmts, medium_fmts, and small_fmts) and use the stored values in the gt pipeline.

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
largemediumsmall
A
12.35 Ɨ 105 -342.2034.00%
21.84 Ɨ 105 -971.7023.00%
33.43 Ɨ 105 -392.6073.00%
42.34 Ɨ 105 -684.5093.00%
sum9.96 Ɨ 105 -2,391.00223.00%
mean2.49 Ɨ 105 -597.7555.75%
sd6.68 Ɨ 104 -291.4132.82%
B
11.91 Ɨ 105 -328.0035.00%
27.48 Ɨ 105 -671.3098.00%
32.53 Ɨ 105 -934.2074.00%
43.44 Ɨ 105 -673.3027.00%
sum1.54 Ɨ 106 -2,606.80234.00%
mean3.84 Ɨ 105 -651.7058.50%
sd2.51 Ɨ 105 -248.6233.39%
- -
-

Passing in parameters like this is useful, especially if there are larger numbers of columns. Additionally, we can store formatting parameters outside of the gt() pipeline and separate our concerns between data structuring and data formatting. The separation of styles and options into objects becomes more important if we intend to centralize formatting options for reuse.

-

Another thing to note in the above example is that even though multiple independent calls of summary_rows() were made, summary data within common summary row names were ā€˜squashedā€™ together, thus avoiding the fragmentation of summary rows. Put another way, we donā€™t create additional summary rows from a group across separate calls if we are referencing the same summary row labels. If the summary row labels provided in fns were to be different across columns, however, additional summary rows would be produced even if the types of data aggregations were to be functionally equivalent.

-
-
- - - -
- - - -
- - - - - diff --git a/docs/articles/gt-datasets.html b/docs/articles/gt-datasets.html deleted file mode 100644 index c33f982263..0000000000 --- a/docs/articles/gt-datasets.html +++ /dev/null @@ -1,4311 +0,0 @@ - - - - - - - -gt Datasets ā€¢ gt - - - - - - - - - - - - - - - - -
-
- - - -
-
- - - - -

The gt package comes with six built-in datasets for experimenting with the gt API: countrypops, sza, gtcars, sp500, pizzaplace, and exibble. While each dataset has different subject matter, all of them will be used to develop gt examples with consistent syntax.

-

-

-

Each dataset is stored as a tibble, ranging from very small (like exibble, an example tibble of 8 rows) to quite large in size (e.g., at nearly 50,000 rows: pizzaplace). Larger datasets are typically impractical as gt output tables but they provide opportunities for demonstrating preprocessing using tidyverse tools like dplyr and tidyr (upstream of gtā€™s gt() entry point).

-

In many gt workflows, there will often be prep work like this where the creation of the input table and any salient information (e.g., metadata for footnotes) will be done alongside the preparation of the display table.

-

In the next few examples, weā€™ll show how tables can be created with each of these datasets. Each example will be preceded with a set of requirements that serve as a design brief. This planning stage can be very useful in your own work for the purpose of organization. The hope is that this collection of simple examples will inspire the creation of much more interesting display tables with gt.

-
-

-countrypops -

-

This dataset provides the total populations of 215 countries on a yearly basis, from 1960 to 2017. The source data comes from the World Bank, where it has been cleaned and tidied up for inclusion into this package. Each row contains a population value for a country in a given year, where NA values for population indicate that the country did not exist in that particular year.

-

The countrypops dataset is a tibble with 12,470 rows and 5 variables. Here are explanations for each of the variables:

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ColumnTypeDescription
country_namechrName of the country
country_code_2chrThe 2-letter ISO 3166-1 country code
country_code_3chrThe 3-letter ISO 3166-1 country code
yearintThe year for the population estimate
populationintThe population estimate, midway through the year
- -
-
-

-A countrypops Example

-

The table that weā€™ll create from countrypops will meet these requirements:

-
    -
  1. use countries from Oceania
  2. -
  3. countries in different regions of Oceania will be grouped together
  4. -
  5. provide populations for the 1995, 2005, and 2015 years only; they should appear as separate columns with a spanner group column stating that these columns refer to population values
  6. -
  7. format population figures to contain commas
  8. -
  9. provide a descriptive title
  10. -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Populations of Oceania's Countries in 1995, 2005, and 2015
Total Population
199520052015
Australasia
Australia18,072,00020,394,80023,850,784
New Zealand3,673,4004,133,9004,595,700
Melanesia
Papua New Guinea4,894,2766,314,7097,919,825
Solomon Islands359,225469,885587,482
New Caledonia193,816232,250272,400
Vanuatu168,235209,370264,603
Micronesia
Guam145,561158,402161,797
Kiribati77,73092,325112,407
Micronesia (Federated States)107,556106,196104,433
Northern Mariana Islands56,27863,74454,816
Marshall Islands51,01552,05552,994
Palau17,25319,90621,288
Nauru9,96910,11412,475
Polynesia
French Polynesia215,196254,886277,690
Samoa170,157179,929193,759
Tonga96,076101,041106,364
Tuvalu9,23010,02711,001
- -
-
-
-
-

-sza -

-

The solar zenith angle is one measure of the solar position. It can be thought of as ā€˜heightā€™ of the sun in relation to an observer. A solar zenith angle of 0Ā° indicates that the sun is directly overhead (a different solar angle, the solar altitude angle, is 90Ā° in this instance). With the sun at the horizontal (e.g., during sunrise/sunset) we observe the solar zenith angle to be around 90Ā° (there is the matter of atmospheric refraction). During nighttime, solar zenith angles in the range of 90ā€“180 are possible (again, depending on the location of the observer).

-

The sza dataset has calculated values for the solar zenith angles every 30 minutes from 04:00 to 12:00 (true solar time). Temporally, these calculations are for the 1st of every month of the year. Spatially, the observer is located at somewhere along latitudes 20Ā°N, 30Ā°N, 40Ā°N, and 50Ā°N (because we are using true solar time, the longitude is unimportant). This is quite an extensive topic, and more information can be found by using ?sza in the R console or by visiting this page.

-

The sza dataset is a tibble with 816 rows and 4 variables. Here are explanations for each of the variables:

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ColumnTypeDescription
latitudedblThe latitude in decimal degrees for the observations
monthfctThe measurement month; all calculations where conducted for the first day of each month
tstchrThe true solar time at the given latitude and date (first of month) for which the solar zenith angle is calculated
szadblThe solar zenith angle in degrees, where NAs indicate that sunrise hadn't yet occurred by the tst value
- -
-
-

-An sza Example

-

The table that weā€™ll create from sza will meet these requirements:

-
    -
  1. filter the data to just use the 20Ā°N data and remove the latitude column
  2. -
  3. -NA values from sza column are to be removed
  4. -
  5. reshape the table so that columns of tst (true solar time) contain angles in degrees (from the sza column)
  6. -
  7. the gt output table will have the months as row labels in the stub
  8. -
  9. missing values will be replaced with an empty string (so that those cells are blank)
  10. -
  11. a stubhead label will state whatā€™s inside the stubs (months, at 20Ā°N)
  12. -
  13. the table will have a heading decorated with the HTML Black Sun with Rays (&#x2600;) symbol
  14. -
  15. to fit the large amount of data in a small area, use some table options to reduce text size and row padding
  16. -
-
# Create a gt table based on a preprocessed `sza`
-sza %>%
-  dplyr::filter(latitude == 20) %>%
-  dplyr::select(-latitude) %>%
-  dplyr::filter(!is.na(sza)) %>%
-  tidyr::spread(key = "tst", value = sza) %>%
-  gt(rowname_col = "month") %>%
-  fmt_missing(
-    columns = TRUE,
-    missing_text = ""
-  ) %>%
-  tab_stubhead_label(label = html("month<br>(20&deg;N)")) %>%
-  tab_header(title = html("&#x2600; Solar Zenith Angles &#x2600;")) %>%
-  tab_options(
-    column_labels.font.size = "smaller",
-    table.font.size = "smaller",
-    row.padding = px(3)
-  )
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ā˜€ Solar Zenith Angles ā˜€
month
(20Ā°N)
05300600063007000730080008300900093010001030110011301200
jan84.978.772.766.161.556.552.148.345.543.643
feb88.982.575.869.663.357.752.247.443.14037.837.2
mar85.778.87265.258.652.346.240.535.531.428.627.7
apr88.581.574.467.460.353.446.539.733.226.921.317.215.5
may8578.271.264.357.250.243.236.129.126.115.28.85
jun89.282.77669.362.555.748.841.93528.121.114.27.32
jul88.882.375.769.162.355.548.741.83528.121.214.37.73.1
aug83.877.170.263.356.449.442.435.428.321.314.37.31.9
sep87.280.273.266.159.152.145.138.131.324.718.613.711.6
oct84.177.170.263.356.549.943.537.53227.424.323.1
nov87.881.374.568.361.85650.245.340.737.435.134.4
dec84.37871.866.160.555.650.947.244.242.441.8
- -
-
-
-
-

-gtcars -

-

The gtcars dataset takes off where mtcars left off. It contains 47 cars from the 2014-2017 model years. Many of the gtcars vehicles are grand tourers. Indeed, many of these provide the ability to cross an entire continent at speed and in comfort yet, when itā€™s called for, they will allow you to experience driving thrills. The chassis and suspension are in most cases top-notch and supply superb handling and roadholding on all routes one would conceivably encounter during the grand touring experience. The two plus two (2 + 2) seating configuration is smartly designed to deliver comfort for a driver and passenger, adequate space for luggage, and have room to spare.

-

The gtcars dataset is a tibble with 47 rows and 15 variables. Here are explanations for each of the variables:

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ColumnTypeDescription
mfrchrThe name of the car manufacturer
modelchrThe car's model name
yearintThe car's model year
trimchrA short description of the car model's trim
bdy_stylechrAn identifier of the car's body style, which is either coupe, convertible, sedan, or hatchback
hp, hp_rpmintThe car's horsepower and the associated RPM level
trq, trq_rpmintThe car's torque and the associated RPM level
mpg_c, mpg_hintThe miles per gallon fuel efficiency rating for city and highway driving
drivetrainchrThe car's drivetrain which, for this dataset is either rwd (Rear Wheel Drive) or awd (All Wheel Drive)
trsmnchrThe codified transmission type, where the number part is the number of gears; the car could have automatic transmission (a), manual transmission (m), an option to switch between both types (am), or, direct drive (dd)
ctry_originchrThe country name for where the vehicle manufacturer is headquartered
- -
-
-

-A gtcars Example

-

The table that weā€™ll create from gtcars will meet these requirements:

-
    -
  1. only include German cars
  2. -
  3. limit the dataset to the top two most expensive offerings from each German manufacturer
  4. -
  5. the information included will be the manufacturer (mfr), the car model (model), the drivetrain, and the price (msrp)
  6. -
  7. add a table title
  8. -
  9. combine the car make and model into a single column
  10. -
  11. capitalize the drivetrain text
  12. -
  13. format the prices as USD currency with commas and no decimal places shown
  14. -
  15. relabel the column headings to provide nicer labels
  16. -
  17. add two footnotes that explain the drivetrain abbreviations and that state the currency of the msrp prices; ensure that the footnote glyphs are lowercase letters
  18. -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select German Automobiles
CarDrivetraina -MSRPb -
BMW i8AWD$140,700
BMW M6RWD$113,400
Audi R8AWD$115,900
Audi S8AWD$114,900
Mercedes-Benz AMG GTRWD$129,900
Mercedes-Benz SL-ClassRWD$85,050
Porsche 911RWD$84,300
Porsche PanameraRWD$78,100
-a AWD = All Wheel Drive, RWD = Rear Wheel Drive.
b Prices in USD.
- -
-
-
-
-

-sp500 -

-

The S&P 500 is a capitalization-weighted index of about 500 leading companies (where bigger companies have more influence within the index) that have common stock listed in either the NYSE or NASDAQ markets. The companies chosen are intended to provide representation of the U.S. economy. This index is a managed list (managed by S&P Dow Jones Indices LLC) with occasional changes of the constituent companies based on their performance and changes in the economy.

-

There is daily S&P 500 data available in the sp500 dataset, with daily indicators (price statistics, volume, etc.) from 1950 to 2015, inclusive. There are 16,607 rows in the dataset, and 7 variables:

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ColumnTypeDescription
datedateThe date expressed as `Date` values
open, high, low, closedblThe day's opening, high, low, and closing prices in USD; the close price is adjusted for splits
volumedblThe number of trades for the given `date`
adj_closedblThe close price adjusted for both dividends and splits
- -
-
-

-An sp500 Example

-

The table that weā€™ll create from sp500 will meet these requirements:

-
    -
  1. use only data from the period 2010-06-02 to 2010-06-15 -
  2. -
  3. the adjusted close adj_close column wonā€™t be included
  4. -
  5. a title and subtitle will be added to describe the contents of the table
  6. -
  7. put the column labels in title case
  8. -
  9. format the date column to appear as ā€˜2 Jun 2010ā€™
  10. -
  11. have the price columns (open, high, low, close) appear in USD
  12. -
  13. the large numbers in volume will be shown as billions (with the B suffix)
  14. -
  15. up- and down-pointing triangles (in green and red) will be added alongside the close price as appropriate
  16. -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
S&P 500
2010-06-02 to 2010-06-15
DateOpenHighLowCloseVolume
15 Jun 2010$1,091.21$1,115.59$1,091.21$1,115.23 ā–² -4.64B
14 Jun 2010$1,095.00$1,105.91$1,089.03$1,089.63 ā–¼ -4.43B
11 Jun 2010$1,082.65$1,092.25$1,077.12$1,091.60 ā–² -4.06B
10 Jun 2010$1,058.77$1,087.85$1,058.77$1,086.84 ā–² -5.14B
9 Jun 2010$1,062.75$1,077.74$1,052.25$1,055.69 ā–¼ -5.98B
8 Jun 2010$1,050.81$1,063.15$1,042.17$1,062.00 ā–² -6.19B
7 Jun 2010$1,065.84$1,071.36$1,049.86$1,050.47 ā–¼ -5.47B
4 Jun 2010$1,098.43$1,098.43$1,060.50$1,064.88 ā–¼ -6.18B
3 Jun 2010$1,098.82$1,105.67$1,091.81$1,102.83 ā–² -5.00B
2 Jun 2010$1,073.01$1,098.56$1,072.03$1,098.38 ā–² -5.03B
- -
-
-
-
-

-pizzaplace -

-

The pizzaplace dataset is unusual to say the least. It brings up more questions than answers. Why is it that the ā€˜The Greekā€™ pizza (the_greek) comes in XL and XXL sizes whilst (almost) all the other pizzas adhere to the S-M-L paradigm? Why is the ā€˜Brie Carreā€™ pizza (brie_carre) only small? Also, is any of this real, and, what is the nature of reality? (All of these questions are quite complicatedā€”while I can doubt the existence of the material world, I cannot doubt the existence of myself as someone thinking about all the delicious pizzas on offer at pizzaplace.)

-

We have the 2015 sales from the pizzaplace, where each row is a pizza sold. There are 32 different types of pizza in 4 different categories: classic, chicken, supreme, and veggie. It was a great year of sales, personal problems notwithstanding. A kitchen fire in late September did not help with the morale situation. Nevertheless, $817,860 in sales for the year! That was indeed something to be cheerful about.

-

Letā€™s learn more about how this fascinating dataset is structured:

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ColumnTypeDescription
idchrThe ID for the order, which consists of one or more pizzas at a given `date` and `time`
datechrA character representation of the order `date`, expressed in the ISO 8601 date format (YYYY-MM-DD)
timechrA character representation of the order time, expressed as a 24-hour time the ISO 8601 extended time format (hh:mm:ss)
namechrThe short name for the pizza
sizechrThe size of the pizza, which can either be S, M, L, XL (rare!), or XXL (even rarer!); most pizzas are available in the S, M, and L sizes but exceptions apply
typechrThe category or type of pizza, which can either be `classic`, `chicken`, `supreme`, or `veggie`
pricedblThe price of the pizza and the amount that it sold for (in USD)
- -
-
-

-A pizzaplace Example

-

Letā€™s make a reporting table from the pizzaplace dataset with these requirements:

-
    -
  1. obtain the total sale numbers and revenue from each size of pizza from each category (type)
  2. -
  3. create a gt table where each row represents a combination of size-type (size provides the row labels and type forms the row groups)
  4. -
  5. add a title to explain the contents of the table
  6. -
  7. format the numeric sold column to use commas and no decimal places
  8. -
  9. format the currency values (income) to be in USD currency
  10. -
  11. add a summary for each grouping that provides total sell counts and revenue amounts
  12. -
  13. color the stub group rows and summary cells to add a little pizzazz
  14. -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Pizzas Sold in 2015
soldincome
chicken
L4,932$102,339.00
M3,894$65,224.50
S2,224$28,356.00
TOTAL11,050$195,919.50
classic
L4,057$74,518.50
M4,112$60,581.75
S6,139$69,870.25
XL552$14,076.00
XXL28$1,006.60
TOTAL14,888$220,053.10
supreme
L4,564$94,258.50
M4,046$66,475.00
S3,377$47,463.50
TOTAL11,987$208,197.00
veggie
L5,403$104,202.70
M3,583$57,101.00
S2,663$32,386.75
TOTAL11,649$193,690.45
- -
-
-
-
-

-exibble -

-

The example tibble thatā€™s useful for gt is called exibble. Itā€™s 8 rows, has clear ordering of data, and the columns contain data that can be tested with the various gt formatter functions (fmt*()). Here is a table describing the columns of exibble:

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ColumnTypeDescription
numdblA numeric column ordered with increasingly larger values
charchrA character column composed of names of fruits from a to h
fctrfctA factor column with numbers from 1 to 8, written out
date, time, datetimechrCharacter columns with dates, times, and datetimes
currencydblA numeric column that is useful for testing currency-based formatting
rowchrA character column in the format `row_X` which can be useful for testing with row label in a table stub
groupchrA character column with four `grp_a` values and four `grp_b` values which can be useful for testing tables that contain row groups
- -
-
-

-An exibble Example

-

Letā€™s test as many formatter functions as possible with exibble while also using row labels and row groups (furnished by the row and group columns). Weā€™ll format num to display numbers with 2 decimal places. The dates in date will be formatted with date_style 6 (the m_day_year style, use info_date_style() to learn about all of them). The 24-h time values in time will use time_style 4 (hm_p, more info at info_time_style()). Datetimes as in datetime column can be formatted with the fmt_datetime() function (which uses the date_style and time_style arguments). The column currency will be formatted as a currency with fmt_currency and weā€™ll consider these values to be euros (currency = "EUR").

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
numcharfctrdatetimedatetimecurrency
grp_a
row_10.11apricotoneJan 15, 20151:35 PMJan 1, 2018 2:22 AMā‚¬49.95
row_22.22bananatwoFeb 15, 20152:40 PMFeb 2, 2018 2:33 PMā‚¬17.95
row_333.33coconutthreeMar 15, 20153:45 PMMar 3, 2018 3:44 AMā‚¬1.39
row_4444.40durianfourApr 15, 20154:50 PMApr 4, 2018 3:55 PMā‚¬65,100.00
grp_b
row_55,550.00NAfiveMay 15, 20155:55 PMMay 5, 2018 4:00 AMā‚¬1,325.81
row_6NAfigsixJun 15, 2015NAJun 6, 2018 4:11 PMā‚¬13.26
row_7777,000.00grapefruitsevenNA7:10 PMJul 7, 2018 5:22 AMNA
row_88,880,000.00honeydeweightAug 15, 20158:20 PMNAā‚¬0.44
- -
-
-
-
- - - -
- - - -
- - - - - diff --git a/docs/articles/images/countrypops.svg b/docs/articles/images/countrypops.svg deleted file mode 100644 index d9f903797b..0000000000 --- a/docs/articles/images/countrypops.svg +++ /dev/null @@ -1,53 +0,0 @@ - - - - countrypops - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/articles/images/exibble.svg b/docs/articles/images/exibble.svg deleted file mode 100644 index 8b602a8026..0000000000 --- a/docs/articles/images/exibble.svg +++ /dev/null @@ -1,115 +0,0 @@ - - - - exibble - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/articles/images/gtcars.svg b/docs/articles/images/gtcars.svg deleted file mode 100644 index 52aa3fde8e..0000000000 --- a/docs/articles/images/gtcars.svg +++ /dev/null @@ -1,29 +0,0 @@ - - - - gtcars - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/articles/images/pizzaplace.svg b/docs/articles/images/pizzaplace.svg deleted file mode 100644 index 3e1d88f284..0000000000 --- a/docs/articles/images/pizzaplace.svg +++ /dev/null @@ -1,35 +0,0 @@ - - - - pizzaplace - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/articles/images/sp500.svg b/docs/articles/images/sp500.svg deleted file mode 100644 index 64d5ec71c5..0000000000 --- a/docs/articles/images/sp500.svg +++ /dev/null @@ -1,295 +0,0 @@ - - - - sp500 - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/articles/images/sza.svg b/docs/articles/images/sza.svg deleted file mode 100644 index 848acd336c..0000000000 --- a/docs/articles/images/sza.svg +++ /dev/null @@ -1,35 +0,0 @@ - - - - sza - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/articles/images/tables_from_the_web.png b/docs/articles/images/tables_from_the_web.png deleted file mode 100644 index 3b360040d8..0000000000 Binary files a/docs/articles/images/tables_from_the_web.png and /dev/null differ diff --git a/docs/articles/index.html b/docs/articles/index.html deleted file mode 100644 index dde7801c85..0000000000 --- a/docs/articles/index.html +++ /dev/null @@ -1,161 +0,0 @@ - - - - - - - - -Articles ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - -
- -
-
- - - -
-
- - -
- - - - - - diff --git a/docs/articles/intro-creating-gt-tables.html b/docs/articles/intro-creating-gt-tables.html deleted file mode 100644 index 22d60cbad5..0000000000 --- a/docs/articles/intro-creating-gt-tables.html +++ /dev/null @@ -1,4073 +0,0 @@ - - - - - - - -Introduction to Creating gt Tables ā€¢ gt - - - - - - - - - - - - - - - - -
-
- - - -
-
- - - - -

The gt package is all about making it simple to produce nice-looking display tables. Display tables? Well yes, we are trying to distinguish between data tables (e.g., tibbles, data.frames, etc.) and those tables youā€™d find in a web page, a journal article, or in a magazine. Such tables can likewise be called presentation tables, summary tables, or just tables really. Here are some examples, ripped straight from the web:

-

-

We can think of display tables as output only, where weā€™d not want to use them as input ever again. Other features include annotations, table element styling, and text transformations that serve to communicate the subject matter more clearly.

-
-

-A Walkthrough of the gt Basics with a Simple Table

-

Letā€™s use a less common dataset that is available in the R datasets package: islands. Itā€™s actually not a data frame but a named vector. Thatā€™s okay though, we can use use dplyr and prepare a tibble from it:

- -

Given that islands_tbl is a tibble, we now have a suitable input for gt.

-

The main entry point into the gt API is the gt() function. If we pass islands_tbl to the function gt(), weā€™ll get a gt Table as output. As an aside, we could have easily used a data frame instead as valid Table Data for gt.

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
namesize
Asia16988
Africa11506
North America9390
South America6795
Antarctica5500
Europe3745
Australia2968
Greenland840
New Guinea306
Borneo280
- -
-

That doesnā€™t look too bad. Sure, itā€™s basic but we really didnā€™t really ask for much. We did receive a proper table with column labels and the data. Also, that default striping is a nice touch. Oftentimes however, youā€™ll want a bit more: a Table header, a Stub, and sometimes footnotes and source notes in the Table Footer part.

-
-
-

-Adding Parts to this Simple Table

-

The gt package makes it relatively easy to add parts so that the resulting gt Table better conveys the information you want to present. These table parts work well together and there the possible variations in arrangement can handle most tabular presentation needs. The previous gt Table demonstrated had only two parts, the Column Labels and the Table Body. The next few examples will show all of the other table parts that are available.

-

This is the way the main parts of a table (and their subparts) fit together:

-

-

-

The parts (roughly from top to bottom) are:

-
    -
  • the Table Header (optional; with a title and possibly a subtitle)
  • -
  • the Stub and the Stub Head (optional; contains row labels, optionally within row groups having row group labels and possibly summary labels when a summary is present)
  • -
  • the Column Labels (contains column labels, optionally under spanner column labels)
  • -
  • the Table Body (contains columns and rows of cells)
  • -
  • the Table Footer (optional; possibly with footnotes and source notes)
  • -
-

The way that we add parts like the Table Header and footnotes in the Table Footer is to use the tab_*() family of functions. A Table Header is easy to add so letā€™s see how the previous table looks with a title and a subtitle. We can add this part using the tab_header() function:

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Large Landmasses of the World
The top ten largest are presented
namesize
Asia16988
Africa11506
North America9390
South America6795
Antarctica5500
Europe3745
Australia2968
Greenland840
New Guinea306
Borneo280
- -
-

The Header table part provides an opportunity to describe the data thatā€™s presented. The subtitle, which functions as a subtitle, is an optional part of the Header. We may also style the title and subtitle using Markdown! We do this by wrapping the values passed to title or subtitle with the md() function. Here is an example with the table data truncated for brevity:

-
# Use markdown for the heading's `title` and `subtitle` to
-# add bold and italicized characters
-gt(islands_tbl[1:2,]) %>%
-  tab_header(
-    title = md("**Large Landmasses of the World**"),
-    subtitle = md("The *top two* largest are presented")
-  )
- -
- - - - - - - - - - - - - - - - - - - - - - - - -
Large Landmasses of the World
The top two largest are presented
namesize
Asia16988
Africa11506
- -
-

A source note can be added to the tableā€™s footer through use of the tab_source_note() function. It works in the same way as tab_header() (it also allows for Markdown inputs) except it can be called multiple timesā€”each invocation results in the addition of a source note.

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Large Landmasses of the World
The top ten largest are presented
namesize
Asia16988
Africa11506
North America9390
South America6795
Antarctica5500
Europe3745
Australia2968
Greenland840
New Guinea306
Borneo280
Source: The World Almanac and Book of Facts, 1975, page 406.
Reference: McNeil, D. R. (1977) Interactive Data Analysis. Wiley.
- -
-

Footnotes live inside the Footer part and their reference glyphs are attached to cell data. Footnotes are added with the tab_footnote() function. The helper function cells_data() can be used with the location argument to specify which data cells should be the target of the footnote. The cells_data() helper has the two arguments columns and rows. For each of these, we can supply (1) a vector of colnames or rownames, (2) a vector of column/row indices, (3) bare column names wrapped in vars() or row labels within c(), or (4) a select helper function (starts_with(), ends_with(), contains(), matches(), one_of(), and everything()). For rows specifically, we can use a conditional statement with column names as variables (e.g., size > 15000).

-

Here is a simple example on how a footnotes can be added to a table cell. Letā€™s add a footnote that references the North America and South America cells in the name column:

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Large Landmasses of the World
The top ten largest are presented
namesize
Asia16988
Africa11506
North America1 -9390
South America1 -6795
Antarctica5500
Europe3745
Australia2968
Greenland840
New Guinea306
Borneo280
Source: The World Almanac and Book of Facts, 1975, page 406.
Reference: McNeil, D. R. (1977) Interactive Data Analysis. Wiley.
-1 The Americas.
- -
-

Here is a slightly more complex example of adding footnotes that use expressions in rows to help target cells in a column by the underlying data in islands_tbl. First, a set of dplyr statements obtains the name of the ā€˜islandā€™ by largest landmass. This is assigned to the largest object and is used in the first tab_footnote() call that targets the cell in the size column that is next to a name value that is stored in largest (ā€™Asiaā€™). The second tab_footnote() is similar except we are supplying a conditional statement that gets the lowest population.

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Large Landmasses of the World
The top ten largest are presented
namesize
Asia169881 -
Africa11506
North America2 -9390
South America2 -6795
Antarctica5500
Europe3745
Australia2968
Greenland840
New Guinea306
Borneo2803 -
Source: The World Almanac and Book of Facts, 1975, page 406.
Reference: McNeil, D. R. (1977) Interactive Data Analysis. Wiley.
-1 The largest by area.
2 The Americas.
3 The lowest by population.
- -
-

We were able to supply the reference locations in the table by using the cells_data() helper function and supplying the necessary targeting through the columns and rows arguments. Other cells_*() functions have similar interfaces and they allow us to target cells in different parts of the table.

-
-
-

-The Stub

-

The Stub is the area to the left in a table that contains row labels, and may contain row group labels, and summary labels. Those subparts can be grouped in a sequence of row groups. The Stub Head provides a location for a label that describes the Stub. The Stub is optional since there are cases where a Stub wouldnā€™t be useful (e.g., the display tables presented above were just fine without a Stub).

-

An easy way to generate a Stub part is by specifying a stub column in the gt() function with the rowname_col argument. Alternatively, we can have an input dataset with a column named rownameā€”this magic column will signal to gt that that column should be used as the stub, making row labels. Letā€™s add a stub with our islands_tbl dataset by modifying the call to gt():

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
size
Asia16988
Africa11506
North America9390
South America6795
Antarctica5500
Europe3745
Australia2968
Greenland840
New Guinea306
Borneo280
- -
-

Notice that the landmass names are off the the left in an unstriped area? Thatā€™s the stub. We can apply whatā€™s known as a stubhead label. This label can be added with the tab_stubhead_label() function:

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
landmasssize
Asia16988
Africa11506
North America9390
South America6795
Antarctica5500
Europe3745
Australia2968
Greenland840
New Guinea306
Borneo280
- -
-

A very important thing to note here is that the table now has one column. Before, when there was no stub, two columns were present (with column labels name and size) but now column number 1 (the only column) is size.

-

To apply our table parts as before (up to and including the footnotes) we use the following statements:

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Large Landmasses of the World
The top ten largest are presented
landmasssize
Asia169881 -
Africa11506
North America9390
South America6795
Antarctica55002 -
Europe3745
Australia2968
Greenland840
New Guinea306
Borneo280
Source: The World Almanac and Book of Facts, 1975, page 406.
Reference: McNeil, D. R. (1977) Interactive Data Analysis. Wiley.
-1 The largest by area.
2 The lowest by population.
- -
-

Letā€™s incorporate row groups into the display table. This divides rows into groups, creating row groups, and results in a display of a row group labels right above the each group. This can be easily done with a table containing row labels. We can make a new row group with each call of the tab_row_group() function. The inputs are group names in the group argument, and row references in the rows argument. We can use any of the strategies to reference rows as we did we footnotes (e.g., vectors of names/indices, select helpers, etc.).

-

Here we will create three row groups (with row group labels continent, country, and subregion) to have a grouping of rows.

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Large Landmasses of the World
The top ten largest are presented
landmasssize
continent
Asia169881 -
Africa11506
North America9390
South America6795
Antarctica55002 -
Europe3745
country
Australia2968
Greenland840
subregion
New Guinea306
Borneo280
Source: The World Almanac and Book of Facts, 1975, page 406.
Reference: McNeil, D. R. (1977) Interactive Data Analysis. Wiley.
-1 The largest by area.
2 The lowest by population.
- -
-

Three row groups have been made since there are three unique categories under groupname. Across the top of each row group is the row group label contained in a separate row (these cut across the field and they contain nothing but the row group label). A rearrangement of rows is carried out to ensure each of the rows is collected within the appropriate row groups.

-

Having groups of rows in row groups is a great way to present information. Including data summaries particular to each group is a natural extension of this idea. This process of adding summary rows with summary labels is covered in a separate article (Creating Summary Lines).

-

Another way to make row groups is to have the magic column groupname present in the input data table. For our above example with islands_tbl, a groupname column with the categories continent, country, and subregion in the appropriate rows would produce row groups automatically (i.e., there would be no need to use the tab_row_group() statements). This strategy of supplying group names in a groupname column name can sometimes be advantageous since we can rely on functions such as those available in dplyr to generate the categories (e.g., using case_when() or if_else()).

-
-
-

-The Column Labels

-

The tableā€™s Column Labels part contains, at a minimum, columns and their column labels. The last example had a single column: size. Just as in the Stub, we can create groupings called spanner columns that encompass one or more columns.

-

To better demonstrate how Column Labels work and are displayed, letā€™s use an input data table with more columns. In this case, that input table will be airquality. It has the following columns:

-
    -
  • -Ozone: mean ground-level ozone in parts per billion by volume (ppbV), measured between 13:00 and 15:00
  • -
  • -Solar.R: solar radiation in Langley units (cal/m2), measured between 08:00 and noon
  • -
  • -Wind: mean wind speed in miles per hour (mph)
  • -
  • -Temp: maximum daily air temperature in degrees Fahrenheit (Ā°F)
  • -
  • -Month, Day: the numeric month and day of month for the record
  • -
-

We know that all measurements took place in 1973, so a year column will be added to the dataset before it is passed to gt().

-

Letā€™s organize the time information under a Time spanner column label, and put the other columns under a Measurement spanner column label. We can do this with the tab_spanner() function.

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New York Air Quality Measurements
Daily measurements in New York City (May 1-10, 1973)
MeasurementTime
OzoneSolar.RWindTempMonthDayYear
411907.467511973
361188.072521973
1214912.674531973
1831311.562541973
NANA14.356551973
28NA14.966561973
232998.665571973
199913.859581973
81920.161591973
NA1948.6695101973
- -
-

We can do two more things to make this presentable:

-
    -
  • move the Time columns to the beginning of the series (using cols_move_to_start())
  • -
  • customize the column labels so that they are more descriptive (using cols_label())
  • -
-

Letā€™s do both of these things in the next example.

- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New York Air Quality Measurements
Daily measurements in New York City (May 1-10, 1973)
TimeMeasurement
YearMonthDayOzone,
ppbV
Solar R.,
cal/m2 -
Wind,
mph
Temp,
Ā°F
197351411907.467
197352361188.072
1973531214912.674
1973541831311.562
197355NANA14.356
19735628NA14.966
197357232998.665
197358199913.859
19735981920.161
1973510NA1948.669
- -
-

Note that even though columns were moved using cols_move_to_start(), the spanner column labels still spanned above the correct column labels. There are a number of functions that gt provides to move columns, including cols_move(), cols_move_to_end(); thereā€™s even a function to hide columns: cols_hide().

-

Multiple columns can be renamed in a single use of cols_label(). Further to this, the helper functions md() and html() can be used to create column labels with additional styling. In the above example, we provided column labels as HTML so that we can insert linebreaks with <br>, insert a superscripted 2 (with <sup>2</sup>), and insert a degree symbol as an HTML entity (&deg;).

-
-
- - - -
- - - -
- - - - - diff --git a/docs/authors.html b/docs/authors.html deleted file mode 100644 index 56cb48706d..0000000000 --- a/docs/authors.html +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - - - -Authors ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - -
- -
-
- - -
    -
  • -

    Richard Iannone. Author, maintainer. ORCID -

    -
  • -
  • -

    Joe Cheng. Author. -

    -
  • -
  • -

    Barret Schloerke. Author. ORCID -

    -
  • -
  • -

    RStudio. Copyright holder, funder. -

    -
  • -
- -
- -
- - - -
- - - - - - diff --git a/docs/docsearch.css b/docs/docsearch.css deleted file mode 100644 index e5f1fe1dfa..0000000000 --- a/docs/docsearch.css +++ /dev/null @@ -1,148 +0,0 @@ -/* Docsearch -------------------------------------------------------------- */ -/* - Source: https://github.com/algolia/docsearch/ - License: MIT -*/ - -.algolia-autocomplete { - display: block; - -webkit-box-flex: 1; - -ms-flex: 1; - flex: 1 -} - -.algolia-autocomplete .ds-dropdown-menu { - width: 100%; - min-width: none; - max-width: none; - padding: .75rem 0; - background-color: #fff; - background-clip: padding-box; - border: 1px solid rgba(0, 0, 0, .1); - box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .175); -} - -@media (min-width:768px) { - .algolia-autocomplete .ds-dropdown-menu { - width: 175% - } -} - -.algolia-autocomplete .ds-dropdown-menu::before { - display: none -} - -.algolia-autocomplete .ds-dropdown-menu [class^=ds-dataset-] { - padding: 0; - background-color: rgb(255,255,255); - border: 0; - max-height: 80vh; -} - -.algolia-autocomplete .ds-dropdown-menu .ds-suggestions { - margin-top: 0 -} - -.algolia-autocomplete .algolia-docsearch-suggestion { - padding: 0; - overflow: visible -} - -.algolia-autocomplete .algolia-docsearch-suggestion--category-header { - padding: .125rem 1rem; - margin-top: 0; - font-size: 1.3em; - font-weight: 500; - color: #00008B; - border-bottom: 0 -} - -.algolia-autocomplete .algolia-docsearch-suggestion--wrapper { - float: none; - padding-top: 0 -} - -.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column { - float: none; - width: auto; - padding: 0; - text-align: left -} - -.algolia-autocomplete .algolia-docsearch-suggestion--content { - float: none; - width: auto; - padding: 0 -} - -.algolia-autocomplete .algolia-docsearch-suggestion--content::before { - display: none -} - -.algolia-autocomplete .ds-suggestion:not(:first-child) .algolia-docsearch-suggestion--category-header { - padding-top: .75rem; - margin-top: .75rem; - border-top: 1px solid rgba(0, 0, 0, .1) -} - -.algolia-autocomplete .ds-suggestion .algolia-docsearch-suggestion--subcategory-column { - display: block; - padding: .1rem 1rem; - margin-bottom: 0.1; - font-size: 1.0em; - font-weight: 400 - /* display: none */ -} - -.algolia-autocomplete .algolia-docsearch-suggestion--title { - display: block; - padding: .25rem 1rem; - margin-bottom: 0; - font-size: 0.9em; - font-weight: 400 -} - -.algolia-autocomplete .algolia-docsearch-suggestion--text { - padding: 0 1rem .5rem; - margin-top: -.25rem; - font-size: 0.8em; - font-weight: 400; - line-height: 1.25 -} - -.algolia-autocomplete .algolia-docsearch-footer { - width: 110px; - height: 20px; - z-index: 3; - margin-top: 10.66667px; - float: right; - font-size: 0; - line-height: 0; -} - -.algolia-autocomplete .algolia-docsearch-footer--logo { - background-image: url("data:image/svg+xml;utf8,"); - background-repeat: no-repeat; - background-position: 50%; - background-size: 100%; - overflow: hidden; - text-indent: -9000px; - width: 100%; - height: 100%; - display: block; - transform: translate(-8px); -} - -.algolia-autocomplete .algolia-docsearch-suggestion--highlight { - color: #FF8C00; - background: rgba(232, 189, 54, 0.1) -} - - -.algolia-autocomplete .algolia-docsearch-suggestion--text .algolia-docsearch-suggestion--highlight { - box-shadow: inset 0 -2px 0 0 rgba(105, 105, 105, .5) -} - -.algolia-autocomplete .ds-suggestion.ds-cursor .algolia-docsearch-suggestion--content { - background-color: rgba(192, 192, 192, .15) -} diff --git a/docs/docsearch.js b/docs/docsearch.js deleted file mode 100644 index b35504cd3a..0000000000 --- a/docs/docsearch.js +++ /dev/null @@ -1,85 +0,0 @@ -$(function() { - - // register a handler to move the focus to the search bar - // upon pressing shift + "/" (i.e. "?") - $(document).on('keydown', function(e) { - if (e.shiftKey && e.keyCode == 191) { - e.preventDefault(); - $("#search-input").focus(); - } - }); - - $(document).ready(function() { - // do keyword highlighting - /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ - var mark = function() { - - var referrer = document.URL ; - var paramKey = "q" ; - - if (referrer.indexOf("?") !== -1) { - var qs = referrer.substr(referrer.indexOf('?') + 1); - var qs_noanchor = qs.split('#')[0]; - var qsa = qs_noanchor.split('&'); - var keyword = ""; - - for (var i = 0; i < qsa.length; i++) { - var currentParam = qsa[i].split('='); - - if (currentParam.length !== 2) { - continue; - } - - if (currentParam[0] == paramKey) { - keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); - } - } - - if (keyword !== "") { - $(".contents").unmark({ - done: function() { - $(".contents").mark(keyword); - } - }); - } - } - }; - - mark(); - }); -}); - -/* Search term highlighting ------------------------------*/ - -function matchedWords(hit) { - var words = []; - - var hierarchy = hit._highlightResult.hierarchy; - // loop to fetch from lvl0, lvl1, etc. - for (var idx in hierarchy) { - words = words.concat(hierarchy[idx].matchedWords); - } - - var content = hit._highlightResult.content; - if (content) { - words = words.concat(content.matchedWords); - } - - // return unique words - var words_uniq = [...new Set(words)]; - return words_uniq; -} - -function updateHitURL(hit) { - - var words = matchedWords(hit); - var url = ""; - - if (hit.anchor) { - url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; - } else { - url = hit.url + '?q=' + escape(words.join(" ")); - } - - return url; -} diff --git a/docs/favicon-16x16.png b/docs/favicon-16x16.png deleted file mode 100644 index d2f6497624..0000000000 Binary files a/docs/favicon-16x16.png and /dev/null differ diff --git a/docs/favicon-32x32.png b/docs/favicon-32x32.png deleted file mode 100644 index 609b3c531b..0000000000 Binary files a/docs/favicon-32x32.png and /dev/null differ diff --git a/docs/favicon.ico b/docs/favicon.ico deleted file mode 100644 index d35aec1fb8..0000000000 Binary files a/docs/favicon.ico and /dev/null differ diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index 18e41591a4..0000000000 --- a/docs/index.html +++ /dev/null @@ -1,231 +0,0 @@ - - - - - - - -Easily Create Presentation-Ready Display Tables ā€¢ gt - - - - - - - - - - - - - - - - -
-
- - - -
-
- - - - - -
- - -

With the gt package, anyone can make wonderful-looking tables using the R programming language. The gt philosophy: we can construct a wide variety of useful tables with a cohesive set of table parts. These include the table header, the stub, the stub head, the column labels, the table body, and the table footer.

-

-

-

It all begins with preprocessed table data (be it a tibble or a data frame). You decide how to compose your gt table with the elements you need for the task at hand. Output can either be in the form of HTML, LaTeX, or RTF. All work beautifully inside R Markdown documents.

-

-

-

The gt API is designed to be both straightforward yet powerful. The emphasis is on simple functions for the everyday display table needs. Here is a brief example of how to use gt to create an HTML gt Table from the included sp500 dataset:

- -

-

-

There are six datasets included in gt: countrypops, sza, gtcars, sp500, pizzaplace, and exibble. All of them are useful for experimenting with the API.

-

-

-

Beyond this simple example, there are many functions available in gt that make it possible to create highly customized tables.

-

-

-

Want to try this out? First and foremost, the gt package is used in an R environment, so, if you donā€™t have an R installation, it can be obtained from the Comprehensive R Archive Network (CRAN). For the best experience in working with R, use the RStudio Desktop IDE.

-

You can install the development version of gt from GitHub. Use the following in the R console to install gt.

-
install.packages("devtools")
-remotes::install_github("rstudio/gt")
-

If you encounter a bug, have usage questions, or want to share ideas to make this package better, feel free to file an issue.

-
-

-
-

-Code of Conduct -

-
-Please note that this project is released with a Contributor Code of Conduct.
By participating in this project you agree to abide by its terms. -
-

-License -

-
-MIT Ā© RStudio, Inc. -
-
-
- - - -
- - - -
- - - - - diff --git a/docs/link.svg b/docs/link.svg deleted file mode 100644 index 88ad82769b..0000000000 --- a/docs/link.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - diff --git a/docs/logo.svg b/docs/logo.svg deleted file mode 100644 index 97b7177bac..0000000000 --- a/docs/logo.svg +++ /dev/null @@ -1,324 +0,0 @@ - - - - gt_hex_logo - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/man/figures/gt_parts_of_a_table.svg b/docs/man/figures/gt_parts_of_a_table.svg deleted file mode 100644 index 147e4a427b..0000000000 --- a/docs/man/figures/gt_parts_of_a_table.svg +++ /dev/null @@ -1,146 +0,0 @@ - - - - gt_parts_of_a_table_svg - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SVG Version - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/news/index.html b/docs/news/index.html deleted file mode 100644 index ce0bafd191..0000000000 --- a/docs/news/index.html +++ /dev/null @@ -1,168 +0,0 @@ - - - - - - - - -Changelog ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - -
- -
-
- - -
-

-gt 0.1.0 (unreleased)

-
    -
  • New package with 39 exported functions for building display tables
  • -
-
-
- - - -
- - -
- - - - - - diff --git a/docs/pkgdown.css b/docs/pkgdown.css deleted file mode 100644 index c03fb08d70..0000000000 --- a/docs/pkgdown.css +++ /dev/null @@ -1,236 +0,0 @@ -/* Sticky footer */ - -/** - * Basic idea: https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/ - * Details: https://github.com/philipwalton/solved-by-flexbox/blob/master/assets/css/components/site.css - * - * .Site -> body > .container - * .Site-content -> body > .container .row - * .footer -> footer - * - * Key idea seems to be to ensure that .container and __all its parents__ - * have height set to 100% - * - */ - -html, body { - height: 100%; -} - -body > .container { - display: flex; - height: 100%; - flex-direction: column; - - padding-top: 60px; -} - -body > .container .row { - flex: 1 0 auto; -} - -footer { - margin-top: 45px; - padding: 35px 0 36px; - border-top: 1px solid #e5e5e5; - color: #666; - display: flex; - flex-shrink: 0; -} -footer p { - margin-bottom: 0; -} -footer div { - flex: 1; -} -footer .pkgdown { - text-align: right; -} -footer p { - margin-bottom: 0; -} - -img.icon { - float: right; -} - -img { - max-width: 100%; -} - -/* Fix bug in bootstrap (only seen in firefox) */ -summary { - display: list-item; -} - -/* Typographic tweaking ---------------------------------*/ - -.contents .page-header { - margin-top: calc(-60px + 1em); -} - -/* Section anchors ---------------------------------*/ - -a.anchor { - margin-left: -30px; - display:inline-block; - width: 30px; - height: 30px; - visibility: hidden; - - background-image: url(./link.svg); - background-repeat: no-repeat; - background-size: 20px 20px; - background-position: center center; -} - -.hasAnchor:hover a.anchor { - visibility: visible; -} - -@media (max-width: 767px) { - .hasAnchor:hover a.anchor { - visibility: hidden; - } -} - - -/* Fixes for fixed navbar --------------------------*/ - -.contents h1, .contents h2, .contents h3, .contents h4 { - padding-top: 60px; - margin-top: -40px; -} - -/* Static header placement on mobile devices */ -@media (max-width: 767px) { - .navbar-fixed-top { - position: absolute; - } - .navbar { - padding: 0; - } -} - - -/* Sidebar --------------------------*/ - -#sidebar { - margin-top: 30px; -} -#sidebar h2 { - font-size: 1.5em; - margin-top: 1em; -} - -#sidebar h2:first-child { - margin-top: 0; -} - -#sidebar .list-unstyled li { - margin-bottom: 0.5em; -} - -.orcid { - height: 16px; - vertical-align: middle; -} - -/* Reference index & topics ----------------------------------------------- */ - -.ref-index th {font-weight: normal;} - -.ref-index td {vertical-align: top;} -.ref-index .icon {width: 40px;} -.ref-index .alias {width: 40%;} -.ref-index-icons .alias {width: calc(40% - 40px);} -.ref-index .title {width: 60%;} - -.ref-arguments th {text-align: right; padding-right: 10px;} -.ref-arguments th, .ref-arguments td {vertical-align: top;} -.ref-arguments .name {width: 20%;} -.ref-arguments .desc {width: 80%;} - -/* Nice scrolling for wide elements --------------------------------------- */ - -table { - display: block; - overflow: auto; -} - -/* Syntax highlighting ---------------------------------------------------- */ - -pre { - word-wrap: normal; - word-break: normal; - border: 1px solid #eee; -} - -pre, code { - background-color: #f8f8f8; - color: #333; -} - -pre code { - overflow: auto; - word-wrap: normal; - white-space: pre; -} - -pre .img { - margin: 5px 0; -} - -pre .img img { - background-color: #fff; - display: block; - height: auto; -} - -code a, pre a { - color: #375f84; -} - -a.sourceLine:hover { - text-decoration: none; -} - -.fl {color: #1514b5;} -.fu {color: #000000;} /* function */ -.ch,.st {color: #036a07;} /* string */ -.kw {color: #264D66;} /* keyword */ -.co {color: #888888;} /* comment */ - -.message { color: black; font-weight: bolder;} -.error { color: orange; font-weight: bolder;} -.warning { color: #6A0366; font-weight: bolder;} - -/* Clipboard --------------------------*/ - -.hasCopyButton { - position: relative; -} - -.btn-copy-ex { - position: absolute; - right: 0; - top: 0; - visibility: hidden; -} - -.hasCopyButton:hover button.btn-copy-ex { - visibility: visible; -} - -/* mark.js ----------------------------*/ - -mark { - background-color: rgba(255, 255, 51, 0.5); - border-bottom: 2px solid rgba(255, 153, 51, 0.3); - padding: 1px; -} - -/* vertical spacing after htmlwidgets */ -.html-widget { - margin-bottom: 10px; -} diff --git a/docs/pkgdown.js b/docs/pkgdown.js deleted file mode 100644 index eb7e83d2fe..0000000000 --- a/docs/pkgdown.js +++ /dev/null @@ -1,115 +0,0 @@ -/* http://gregfranko.com/blog/jquery-best-practices/ */ -(function($) { - $(function() { - - $("#sidebar") - .stick_in_parent({offset_top: 40}) - .on('sticky_kit:bottom', function(e) { - $(this).parent().css('position', 'static'); - }) - .on('sticky_kit:unbottom', function(e) { - $(this).parent().css('position', 'relative'); - }); - - $('body').scrollspy({ - target: '#sidebar', - offset: 60 - }); - - $('[data-toggle="tooltip"]').tooltip(); - - var cur_path = paths(location.pathname); - var links = $("#navbar ul li a"); - var max_length = -1; - var pos = -1; - for (var i = 0; i < links.length; i++) { - if (links[i].getAttribute("href") === "#") - continue; - // Ignore external links - if (links[i].host !== location.host) - continue; - - var nav_path = paths(links[i].pathname); - - var length = prefix_length(nav_path, cur_path); - if (length > max_length) { - max_length = length; - pos = i; - } - } - - // Add class to parent
  • , and enclosing
  • if in dropdown - if (pos >= 0) { - var menu_anchor = $(links[pos]); - menu_anchor.parent().addClass("active"); - menu_anchor.closest("li.dropdown").addClass("active"); - } - }); - - function paths(pathname) { - var pieces = pathname.split("/"); - pieces.shift(); // always starts with / - - var end = pieces[pieces.length - 1]; - if (end === "index.html" || end === "") - pieces.pop(); - return(pieces); - } - - // Returns -1 if not found - function prefix_length(needle, haystack) { - if (needle.length > haystack.length) - return(-1); - - // Special case for length-0 haystack, since for loop won't run - if (haystack.length === 0) { - return(needle.length === 0 ? 0 : -1); - } - - for (var i = 0; i < haystack.length; i++) { - if (needle[i] != haystack[i]) - return(i); - } - - return(haystack.length); - } - - /* Clipboard --------------------------*/ - - function changeTooltipMessage(element, msg) { - var tooltipOriginalTitle=element.getAttribute('data-original-title'); - element.setAttribute('data-original-title', msg); - $(element).tooltip('show'); - element.setAttribute('data-original-title', tooltipOriginalTitle); - } - - if(ClipboardJS.isSupported()) { - $(document).ready(function() { - var copyButton = ""; - - $(".examples, div.sourceCode").addClass("hasCopyButton"); - - // Insert copy buttons: - $(copyButton).prependTo(".hasCopyButton"); - - // Initialize tooltips: - $('.btn-copy-ex').tooltip({container: 'body'}); - - // Initialize clipboard: - var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { - text: function(trigger) { - return trigger.parentNode.textContent; - } - }); - - clipboardBtnCopies.on('success', function(e) { - changeTooltipMessage(e.trigger, 'Copied!'); - e.clearSelection(); - }); - - clipboardBtnCopies.on('error', function() { - changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); - }); - }); - } -})(window.jQuery || window.$) diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml deleted file mode 100644 index 3836c64582..0000000000 --- a/docs/pkgdown.yml +++ /dev/null @@ -1,12 +0,0 @@ -pandoc: '2.4' -pkgdown: 1.3.0.9000 -pkgdown_sha: fa9b7502e80401db4b410086b0a8f6ab444f0c66 -articles: - case-study-gtcars: case-study-gtcars.html - creating-summary-lines: creating-summary-lines.html - gt-datasets: gt-datasets.html - intro-creating-gt-tables: intro-creating-gt-tables.html -urls: - reference: https://gt.rstudio.com/reference - article: https://gt.rstudio.com/articles - diff --git a/docs/reference/adjust_luminance.html b/docs/reference/adjust_luminance.html deleted file mode 100644 index b375f2dc1f..0000000000 --- a/docs/reference/adjust_luminance.html +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - - - -Adjust the luminance for a palette of colors ā€” adjust_luminance ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    This function can brighten or darken a palette of colors by an arbitrary -number of steps, which is defined by a real number between -2.0 and 2.0. The -transformation of a palette by a fixed step in this function will tend to -apply greater darkening or lightening for those colors in the midrange -compared to any very dark or very light colors in the input palette.

    - -
    - -
    adjust_luminance(colors, steps)
    - -

    Arguments

    - - - - - - - - - - -
    colors

    a vector of colors that will undergo an adjustment in -luminance. Each color value provided must either be a color name (in the -set of colors provided by grDevices::colors()) or a hexadecimal -string in the form of "#RRGGBB" or "#RRGGBBAA".

    steps

    a positive or negative factor by which the luminance will be -adjusted. Must be a number between -2.0 and 2.0.

    - -

    Details

    - -

    This function can be useful when combined with the data_color() -function's palette argument, which can use a vector of colors or any -of the col_* functions from the scales package (all of which -have a palette argument).

    - -

    Figures

    - - -

    - - -

    Examples

    -
    # Get a palette of 8 pastel colors from -# the RColorBrewer package -pal <- RColorBrewer::brewer.pal(8, "Pastel2") - -# Create lighter and darker variants -# of the base palette (one step lower, one -# step higher) -pal_darker <- pal %>% adjust_luminance(-1.0) -pal_lighter <- pal %>% adjust_luminance(+1.0) - -# Create a tibble and make a gt table -# from it; color each column in order of -# increasingly darker palettes (with -# `data_color()`) -tab_1 <- - dplyr::tibble(a = 1:8, b = 1:8, c = 1:8) %>% - gt() %>% - data_color( - columns = vars(a), - colors = scales::col_numeric( - palette = pal_lighter, - domain = c(1, 8) - ) - ) %>% - data_color( - columns = vars(b), - colors = scales::col_numeric( - palette = pal, - domain = c(1, 8) - ) - ) %>% - data_color( - columns = vars(c), - colors = scales::col_numeric( - palette = pal_darker, - domain = c(1, 8) - ) - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/as_latex.html b/docs/reference/as_latex.html deleted file mode 100644 index 03b1f08f72..0000000000 --- a/docs/reference/as_latex.html +++ /dev/null @@ -1,237 +0,0 @@ - - - - - - - - -Output a <span class="pkg">gt</span> object as LaTeX ā€” as_latex ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -gt object as LaTeX ā€” as_latex" /> - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Get the LaTeX content from a gt_tbl object as a knit_asis -object. This object contains the LaTeX code and attributes that serve as -LaTeX dependencies (i.e., the LaTeX packages required for the table). Using -as.character() on the created object will result in a single-element -vector containing the LaTeX code.

    - -
    - -
    as_latex(data)
    - -

    Arguments

    - - - - - - -
    data

    a table object that is created using the gt() -function.

    - -

    See also

    - -

    Other table export functions: as_raw_html, - as_rtf, extract_summary

    - - -

    Examples

    -
    # Use `gtcars` to create a gt table; -# add a header and then export as -# an object with LaTeX code -tab_latex <- - gtcars %>% - dplyr::select(mfr, model, msrp) %>% - dplyr::slice(1:5) %>% - gt() %>% - tab_header( - title = md("Data listing from **gtcars**"), - subtitle = md("`gtcars` is an R dataset") - ) %>% - as_latex() - -# `tab_latex` is a `knit_asis` object, -# which makes it easy to include in -# R Markdown documents that are knit to -# PDF; we can use `as.character()` to -# get just the LaTeX code as a single- -# element vector -tab_latex %>% - as.character() %>% - cat()
    #> \captionsetup[table]{labelformat=empty,skip=1pt} -#> \begin{longtable}{llr} -#> \caption*{ -#> \large Data listing from \textbf{gtcars}\\ -#> \small \texttt{gtcars} is an R dataset\\ -#> } \\ -#> \toprule -#> mfr & model & msrp \\ -#> \midrule -#> Ford & GT & 447000 \\ -#> Ferrari & 458 Speciale & 291744 \\ -#> Ferrari & 458 Spider & 263553 \\ -#> Ferrari & 458 Italia & 233509 \\ -#> Ferrari & 488 GTB & 245400 \\ -#> \bottomrule -#> \end{longtable}
    -
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/as_raw_html.html b/docs/reference/as_raw_html.html deleted file mode 100644 index e913e34c4a..0000000000 --- a/docs/reference/as_raw_html.html +++ /dev/null @@ -1,235 +0,0 @@ - - - - - - - - -Get the HTML content of a <span class="pkg">gt</span> table ā€” as_raw_html ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -gt table ā€” as_raw_html" /> - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Get the HTML content from a gt_tbl object as a single-element -character vector. By default, the generated HTML will have inlined styles, -where CSS styles (that were previously contained in CSS rule sets external to -the <table> element) are included as style attributes in the -HTML table's tags. This option is preferable when using the output HTML table -in an emailing context.

    - -
    - -
    as_raw_html(data, inline_css = TRUE)
    - -

    Arguments

    - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    inline_css

    an option to supply styles to table elements as inlined CSS -styles.

    - -

    See also

    - -

    Other table export functions: as_latex, - as_rtf, extract_summary

    - - -

    Examples

    -
    # Use `gtcars` to create a gt table; -# add a header and then export as -# HTML code with CSS inlined -tab_html <- - gtcars %>% - dplyr::select(mfr, model, msrp) %>% - dplyr::slice(1:5) %>% - gt() %>% - tab_header( - title = md("Data listing from **gtcars**"), - subtitle = md("`gtcars` is an R dataset") - ) %>% - as_raw_html() - -# `tab_html` is a single-element vector -# containing inlined HTML for the table; -# it has only the `<table>...</table>` part -# so it's not a complete HTML document but -# rather an HTML fragment -tab_html %>% - substr(1, 700) %>% - cat()
    #> <!--gt table start--> -#> <table style="font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif;display:table;border-collapse:collapse;margin-left:auto;margin-right:auto;color:#000000;font-size:16px;background-color:#FFFFFF;width:auto;border-top-style:solid;border-top-width:2px;border-top-color:#A8A8A8;"> -#> <thead> -#> <tr> -#> <th colspan='3' style="background-color:#FFFFFF;border-bottom-color:#FFFFFF;color:#000000;font-size:125%;padding-top:4px;padding-bottom:1px;border-bottom-width:0;text-align:center;font-weight:normal;" >Data listing from <strong>gtcars</strong></th> -#> </tr> -#> <tr> -#> <th colspan='3' style="
    -
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/as_rtf.html b/docs/reference/as_rtf.html deleted file mode 100644 index 6d7b0447df..0000000000 --- a/docs/reference/as_rtf.html +++ /dev/null @@ -1,263 +0,0 @@ - - - - - - - - -Output a <span class="pkg">gt</span> object as RTF ā€” as_rtf ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -gt object as RTF ā€” as_rtf" /> - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Get the RTF content from a gt_tbl object as as a single-element -character vector. This object can be used with writeLines() to -generate a valid .rtf file that can be opened by RTF readers.

    - -
    - -
    as_rtf(data)
    - -

    Arguments

    - - - - - - -
    data

    a table object that is created using the gt() function.

    - -

    See also

    - -

    Other table export functions: as_latex, - as_raw_html, extract_summary

    - - -

    Examples

    -
    # Use `gtcars` to create a gt table; -# add a header and then export as -# RTF code -tab_rtf <- - gtcars %>% - dplyr::select(mfr, model) %>% - dplyr::slice(1:2) %>% - gt() %>% - tab_header( - title = md("Data listing from **gtcars**"), - subtitle = md("`gtcars` is an R dataset") - ) %>% - as_rtf() - -# `tab_rtf` is a single element character -# vector -tab_rtf %>% cat()
    #> {\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf400 -#> {\fonttbl\f0\fswiss\fcharset0 Helvetica;} -#> {\colortbl;\red255\green255\blue255; -#> } -#> {\*\expandedcolortbl;;\cssrgb\c0\c0\c0;\cssrgb\c37036\c37036\c37036;\csgray\c0\c0; -#> } -#> \deftab20 -#> \cf0 -#> \itap1\trowd \taflags1 \trgaph108\trleft-108 \trbrdrt\brdrnil \trbrdrl\brdrnil \trbrdrr\brdrnil -#> \clmgf \clvertalb \clshdrawnil \clheight340 \clbrdrt\brdrs\brdrw40\brdrcf3 \clbrdrl\brdrnil \clbrdrb\brdrnil \clbrdrr\brdrnil \clpadl100 \clpadr100 \clpadt100 \gaph\cellx935 -#> \clmrg \clvertalb \clshdrawnil \clheight340 \clbrdrt\brdrs\brdrw40\brdrcf3 \clbrdrl\brdrnil \clbrdrb\brdrnil \clbrdrr\brdrnil \clpadl100 \clpadr100 \clpadt100 \gaph\cellx1870 -#> \pard\intbl\itap1\pardeftab20\qc\partightenfactor0 -#> \f0\fs36 \expnd0\expndtw0\kerning0 -#> \up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec2 Data listing from **gtcars** -#> \fs24 \kerning1\expnd0\expndtw0 \up0 \nosupersub \ulnone \outl0\strokewidth0 \cell -#> \pard\intbl\itap1\cell -#> \row -#> -#> \itap1\trowd \taflags1 \trgaph108\trleft-108 \trbrdrl\brdrnil \trbrdrr\brdrnil -#> \clmgf \clvertalc \clshdrawnil \clheight240 \clbrdrt\brdrnil \clbrdrl\brdrnil \clbrdrb\brdrs\brdrw40\brdrcf3 \clbrdrr\brdrnil \clpadl100 \clpadr100 \clpadb100 \gaph\cellx935 -#> \clmrg \clvertalc \clshdrawnil \clheight240 \clbrdrt\brdrnil \clbrdrl\brdrnil \clbrdrb\brdrs\brdrw40\brdrcf3 \clbrdrr\brdrnil \clpadl100 \clpadr100 \clpadb100 \gaph\cellx1870 -#> \pard\intbl\itap1\pardeftab20\qc\partightenfactor0 -#> -#> \fs20 \expnd0\expndtw0\kerning0\up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec2 `gtcars` is an R dataset -#> \fs28 \kerning1\expnd0\expndtw0 \up0 \nosupersub \ulnone \outl0\strokewidth0 \cell\pard\intbl\itap1\cell -#> \row\itap1\trowd \taflags1 \trgaph108\trleft-108 \trbrdrl\brdrnil \trbrdrr\brdrnil -#> \clvertalc \clshdrawnil \clheight520 \clbrdrt\brdrs\brdrw40\brdrcf3 \clbrdrl\brdrnil \clbrdrb\brdrs\brdrw40\brdrcf3 \clbrdrr\brdrnil \clpadl100 \clpadr100 \gaph\cellx935 -#> \clvertalc \clshdrawnil \clheight520 \clbrdrt\brdrs\brdrw40\brdrcf3 \clbrdrl\brdrnil \clbrdrb\brdrs\brdrw40\brdrcf3 \clbrdrr\brdrnil \clpadl100 \clpadr100 \gaph\cellx1870 -#> \pard\intbl\itap1\pardeftab20\qc\partightenfactor0 -#> \expnd0\expndtw0\kerning0 -#> \up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec2 mfr \kerning1\expnd0\expndtw0 \up0 \nosupersub \ulnone \outl0\strokewidth0 \cell -#> \pard\intbl\itap1\pardeftab20\qc\partightenfactor0 -#> \expnd0\expndtw0\kerning0 -#> \up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec2 model \kerning1\expnd0\expndtw0 \up0 \nosupersub \ulnone \outl0\strokewidth0 \cell -#> \row\itap1\trowd \taflags1 \trgaph108\trleft-108 \trbrdrl\brdrnil \trbrdrr\brdrnil -#> \clvertalc \clshdrawnil \clbrdrt\brdrnil \clbrdrl\brdrnil \clbrdrb\brdrnil \clbrdrr\brdrnil \clpadl100 \clpadr100 \clpadt50 \clpadb50 \gaph\cellx935 -#> \clvertalc \clshdrawnil \clbrdrt\brdrnil \clbrdrl\brdrnil \clbrdrb\brdrnil \clbrdrr\brdrnil \clpadl100 \clpadr100 \clpadt50 \clpadb50 \gaph\cellx1870 -#> \pard\intbl\itap1\pardeftab20\qc\partightenfactor0 -#> \expnd0\expndtw0\kerning0 -#> \up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec2 Ford \kerning1\expnd0\expndtw0 \up0 \nosupersub \ulnone \outl0\strokewidth0 \cell -#> \pard\intbl\itap1\pardeftab20\qc\partightenfactor0 -#> \expnd0\expndtw0\kerning0 -#> \up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec2 GT \kerning1\expnd0\expndtw0 \up0 \nosupersub \ulnone \outl0\strokewidth0 \cell -#> \row\itap1\trowd \taflags1 \trgaph108\trleft-108 \trbrdrl\brdrnil \trbrdrr\brdrnil -#> \clvertalc \clshdrawnil \clbrdrt\brdrnil \clbrdrl\brdrnil \clbrdrb\brdrs\brdrw40\brdrcf3 \clbrdrr\brdrnil \clpadl100 \clpadr100 \clpadt50 \clpadb50 \gaph\cellx935 -#> \clvertalc \clshdrawnil \clbrdrt\brdrnil \clbrdrl\brdrnil \clbrdrb\brdrs\brdrw40\brdrcf3 \clbrdrr\brdrnil \clpadl100 \clpadr100 \clpadt50 \clpadb50 \gaph\cellx1870 -#> \pard\intbl\itap1\pardeftab20\qc\partightenfactor0 -#> \expnd0\expndtw0\kerning0 -#> \up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec2 Ferrari \kerning1\expnd0\expndtw0 \up0 \nosupersub \ulnone \outl0\strokewidth0 \cell -#> \pard\intbl\itap1\pardeftab20\qc\partightenfactor0 -#> \expnd0\expndtw0\kerning0 -#> \up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec2 458 Speciale \kerning1\expnd0\expndtw0 \up0 \nosupersub \ulnone \outl0\strokewidth0\expnd0\expndtw0\kerning0 -#> \up0 \nosupersub \ulnone \outl0\strokewidth0 \strokec2 \cell \lastrow\row}
    -
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/cells_styles.html b/docs/reference/cells_styles.html deleted file mode 100644 index 7a7e7c5b37..0000000000 --- a/docs/reference/cells_styles.html +++ /dev/null @@ -1,263 +0,0 @@ - - - - - - - - -Helper for defining custom styles for table cells ā€” cells_styles ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    This helper function is to be used with the tab_style() -function, which itself allows for the setting of custom styles to one or more -cells. We can also define several styles within a single call of -cells_styles and tab_style() will reliably apply those -styles to the targeted element.

    - -
    - -
    cells_styles(bkgd_color = NULL, text_color = NULL, text_font = NULL,
    -  text_size = NULL, text_align = NULL, text_style = NULL,
    -  text_weight = NULL, text_stretch = NULL, text_indent = NULL,
    -  text_decorate = NULL, text_transform = NULL)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    bkgd_color

    the background color of the cell.

    text_color

    the text color.

    text_font

    the font or collection of fonts (subsequent font names are) -used as fallbacks.

    text_size

    the size of the font. Can be provided as a number that is -assumed to represent px values (or could be wrapped in the -px()) helper function. We can also use one of the following -absolute size keywords: xx-small, x-small, small, -medium, large, x-large, or xx-large.

    text_align

    the text alignment. Can be one of either "center", -"left", "right", or "justify".

    text_style

    the text style. Can be one of either "center", -"normal", "italic", or "oblique".

    text_weight

    the weight of the font. Can be a text-based keyword such -as "normal", "bold", "lighter", "bolder", or, a -numeric value between 1 and 1000, inclusive. Note that only -variable fonts may support the numeric mapping of weight.

    text_stretch

    allows for text to either be condensed or expanded. We -can use the following text-based keywords to describe the degree of -condensation/expansion: ultra-condensed, extra-condensed, -condensed, semi-condensed, normal, -semi-expanded, expanded, extra-expanded, and -ultra-expanded. Alternatively, we can supply percentage values from -0% to 200%, inclusive. Negative percentage values are not -allowed.

    text_indent

    the indentation of the text.

    text_decorate

    allows for text decoration effect to be applied. Here, -we can use "overline", "line-through", or "underline".

    text_transform

    allows for the transformation of text. Options are -"uppercase", "lowercase", or "capitalize".

    - -

    Value

    - -

    a character vector containing formatted styles.

    - -

    See also

    - -

    Other helper functions: escape_latex, - gt_latex_dependencies, html, - md, pct, px

    - - -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/cols_align.html b/docs/reference/cols_align.html deleted file mode 100644 index 2230a66304..0000000000 --- a/docs/reference/cols_align.html +++ /dev/null @@ -1,254 +0,0 @@ - - - - - - - - -Set the alignment of columns ā€” cols_align ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    The individual alignments of columns (which includes the column labels and -all of their data cells) can be modified. We have the option to align text to -the left, the center, and the right. In a less explicit -manner, we can allow gt to automatically choose the alignment of each -column based on the data type (with the auto option).

    - -
    - -
    cols_align(data, align = c("auto", "left", "center", "right"),
    -  columns = TRUE)
    - -

    Arguments

    - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    align

    the alignment type. This can be any of "center", -"left", or "right" for center-, left-, or center-alignment. -Alternatively, the "auto" option (the default), will automatically -align values in columns according to the data type (see the Details section -for specifics on which alignments are applied).

    columns

    an optional vector of column names for which the alignment -should be applied. If nothing is supplied, or if columns is -TRUE), then the chosen alignment affects all columns.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Details

    - -

    When you create a gt table object using gt(), automatic -alignment of column labels and their data cells is performed. By default, -left-alignment is applied to columns of class character, Date, -or POSIXct; center-alignment is for columns of class logical, -factor, or list; and right-alignment is used for the -numeric and integer columns.

    - -

    Figures

    - - -

    - -

    See also

    - - - - -

    Examples

    -
    # Use `countrypops` to create a gt table; -# align the `population` column data to -# the left -tab_1 <- - countrypops %>% - dplyr::select(-contains("code")) %>% - dplyr::filter(country_name == "Mongolia") %>% - tail(5) %>% - gt() %>% - cols_align( - align = "left", - columns = vars(population) - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/cols_hide.html b/docs/reference/cols_hide.html deleted file mode 100644 index 70ea9a011c..0000000000 --- a/docs/reference/cols_hide.html +++ /dev/null @@ -1,267 +0,0 @@ - - - - - - - - -Hide one or more columns ā€” cols_hide ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    The cols_hide() function allows us to hide one or more columns from -appearing in the final output table. While it's possible and often desirable -to omit columns from the input table data before introduction to the -gt() function, there can be cases where the data in certain -columns is useful (as a column reference during formatting of other columns) -but the final display of those columns is not necessary.

    - -
    - -
    cols_hide(data, columns)
    - -

    Arguments

    - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    columns

    the column names to hide from the output display table. The -order of the remaining columns will be preserved. Values provided that do -not correspond to column names will be disregarded.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Details

    - -

    The hiding of columns is internally a rendering directive, so, all columns -that are 'hidden' are still accessible and useful in any expression provided -to a rows argument. Furthermore, the cols_hide() function (as -with many gt functions) can be placed anywhere in a pipeline of -gt function calls (acting as a promise to hide columns when the timing -is right). However there's perhaps greater readability when placing this call -closer to the end of such a pipeline.

    - -

    Figures

    - - -

    -

    - -

    See also

    - - - - -

    Examples

    -
    # Use `countrypops` to create a gt table; -# Hide the columns `country_code_2` and -# `country_code_3` -tab_1 <- - countrypops %>% - dplyr::filter(country_name == "Mongolia") %>% - tail(5) %>% - gt() %>% - cols_hide( - columns = vars( - country_code_2, country_code_3) - ) - -# Use `countrypops` to create a gt table; -# Use the `population` column to provide -# the conditional placement of footnotes, -# then hide that column and one other -tab_2 <- - countrypops %>% - dplyr::filter(country_name == "Mongolia") %>% - tail(5) %>% - gt() %>% - cols_hide( - columns = vars(country_code_3, population) - ) %>% - tab_footnote( - footnote = "Population above 3,000,000.", - locations = cells_data( - columns = vars(year), - rows = population > 3000000) - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/cols_label.html b/docs/reference/cols_label.html deleted file mode 100644 index 57fc59d860..0000000000 --- a/docs/reference/cols_label.html +++ /dev/null @@ -1,273 +0,0 @@ - - - - - - - - -Relabel one or more columns ā€” cols_label ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Column labels can be modified from their default values (the names of the -columns from the input table data). When you create a gt table object -using gt(), column names effectively become the column labels. -While this serves as a good first approximation, column names aren't often -appealing as column labels in a gt output table. The -cols_label() function provides the flexibility to relabel one or more -columns and we even have the option to use the md() or -html() helper functions for rendering column labels from -Markdown or using HTML.

    - -
    - -
    cols_label(data, ..., .list = list2(...))
    - -

    Arguments

    - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    ...

    one or more named arguments of column names from the input `data` -table along with their labels for display as the column labels. We can -optionally wrap the column labels with md() (to interpret -text as Markdown) or html() (to interpret text as HTML).

    .list

    allows for the use of a list as an input alternative to -....

    - -

    Details

    - -

    It's important to note that while columns can be freely relabeled, we -continue to refer to columns by their original column names. Column names in -a tibble or data frame must be unique whereas column labels in gt -have no requirement for uniqueness (which is useful for labeling columns as, -say, measurement units that may be repeated several times---usually under -different spanner column labels). Thus, we can still easily distinguish -between columns in other gt function calls (e.g., in all of the -fmt*() functions) even though we may lose distinguishability in column -labels once they have been relabeled.

    - -

    Figures

    - - -

    -

    - -

    See also

    - - - - -

    Examples

    -
    # Use `countrypops` to create a gt table; -# label all the table's columns to -# present better -tab_1 <- - countrypops %>% - dplyr::select(-contains("code")) %>% - dplyr::filter(country_name == "Mongolia") %>% - tail(5) %>% - gt() %>% - cols_label( - country_name = "Name", - year = "Year", - population = "Population" - ) - -# Use `countrypops` to create a gt table; -# label columns as before but make them -# bold with markdown formatting -tab_2 <- - countrypops %>% - dplyr::select(-contains("code")) %>% - dplyr::filter(country_name == "Mongolia") %>% - tail(5) %>% - gt() %>% - cols_label( - country_name = md("**Name**"), - year = md("**Year**"), - population = md("**Population**") - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/cols_merge.html b/docs/reference/cols_merge.html deleted file mode 100644 index d6ddf0c6e9..0000000000 --- a/docs/reference/cols_merge.html +++ /dev/null @@ -1,273 +0,0 @@ - - - - - - - - -Merge two columns to a single column ā€” cols_merge ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    This function takes any two columns and merges them into a single column, -using a pattern that specifies how the values in the data cells are combined. -We specify the columns to merge together in the col_1 and col_2 -arguments and the string-combining pattern is specified in pattern. -The column that is retained is that of col_1 whereas the column -specified in col_2 is dropped from the output table.

    - -
    - -
    cols_merge(data, col_1, col_2, pattern = "{1} {2}")
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    col_1

    a retained column that contains values to be merged with those -in col_2.

    col_2

    a column that contains values to be merged with those in -col_1. This column will be discarded but is still useful as a -reference in other gt functions.

    pattern

    a formatting pattern that specifies the arrangement of the -col_1 and col_1 values and any string literals. The -col_1 column is represented as {1} whereas col_2 is -{2}. All other characters are taken to be string literals.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Details

    - -

    There are two other column-merging functions that offer specialized behavior -that is optimized for common table tasks: cols_merge_range() -and cols_merge_uncert(). These functions operate similarly, -where the second column specified is dropped from the output table. For all -of the cols_merge*() functions, column removal occurs late in the -rendering lifecycle so those secondary columns are still usable as column -references (e.g., inside expressions provided to `rows` in the fmt*() -functions).

    - -

    Figures

    - - -

    - -

    See also

    - - - - -

    Examples

    -
    # Use `sp500` to create a gt table; -# merge the `open` & `close` columns -# together, and, the `low` & `high` -# columns (putting an em dash between -# both); rename the columns -tab_1 <- - sp500 %>% - dplyr::slice(50:55) %>% - dplyr::select(-volume, -adj_close) %>% - gt() %>% - cols_merge( - col_1 = vars(open), - col_2 = vars(close), - pattern = "{1}&mdash;{2}" - ) %>% - cols_merge( - col_1 = vars(low), - col_2 = vars(high), - pattern = "{1}&mdash;{2}" - ) %>% - cols_label( - open = "open/close", - low = "low/high" - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/cols_merge_range.html b/docs/reference/cols_merge_range.html deleted file mode 100644 index da50b4571d..0000000000 --- a/docs/reference/cols_merge_range.html +++ /dev/null @@ -1,271 +0,0 @@ - - - - - - - - -Merge two columns to a value range column ā€” cols_merge_range ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    The cols_merge_range() function is a specialized variant of the -cols_merge() function. It operates by taking a two columns that -constitute a range of values (col_begin and col_end) and merges -them into a single column. What results is a column containing both values -separated by a long dash (e.g., 12.0 ā€” 20.0). The column specified in -col_end is dropped from the output table.

    - -
    - -
    cols_merge_range(data, col_begin, col_end)
    - -

    Arguments

    - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    col_begin

    a column that contains values for the start of the range.

    col_end

    a column that contains values for the end of the range.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Details

    - -

    This function could be somewhat replicated using cols_merge(), -however, cols_merge_range() employs the following specialized -semantics for NA handling:

    -
      -
    1. NAs in col_begin result in missing values for the merged -column (e.g., NA + 20.0 = NA)

    2. -
    3. NAs in col_end (but not col_begin) result in -a display of only the col_begin values only for the merged column -(e.g., 12.0 + NA = 12.0)

    4. -
    5. NAs both col_begin and col_end result in -missing values for the merged column (e.g., NA + NA = -NA)

    6. -
    -

    Any resulting NA values in the col_begin column following the -merge operation can be easily formatted using the fmt_missing() -function.

    -

    This function is part of a set of three column-merging functions. The other -two are the general cols_merge() function and the specialized -cols_merge_uncert() function. These functions operate -similarly, where the second column specified is dropped from the output -table. For all of the cols_merge*() functions, column removal occurs -late in the rendering lifecycle so those secondary columns are still usable -as column references (e.g., inside expressions provided to `rows` in the -fmt*() functions).

    - -

    Figures

    - - -

    - -

    See also

    - - - - -

    Examples

    -
    # Use `gtcars` to create a gt table, -# keeping only the `model`, `mpg_c`, -# and `mpg_h` columns; merge the mpg -# columns together as a single range -# column (which is labeled as MPG, -# in italics) -tab_1 <- - gtcars %>% - dplyr::select(model, starts_with("mpg")) %>% - dplyr::slice(1:8) %>% - gt() %>% - cols_merge_range( - col_begin = vars(mpg_c), - col_end = vars(mpg_h)) %>% - cols_label( - mpg_c = md("*MPG*") - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/cols_merge_uncert.html b/docs/reference/cols_merge_uncert.html deleted file mode 100644 index 372b8cf772..0000000000 --- a/docs/reference/cols_merge_uncert.html +++ /dev/null @@ -1,275 +0,0 @@ - - - - - - - - -Merge two columns to a value & uncertainty column ā€” cols_merge_uncert ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    The cols_merge_uncert() function is a specialized variant of the -cols_merge() function. It operates by taking a base value -column (col_val) and an uncertainty column (col_uncert) and -merges them into a single column. What results is a column with values and -associated uncertainties (e.g., 12.0 Ā± 0.1), and, the column specified -in col_uncert is dropped from the output table.

    - -
    - -
    cols_merge_uncert(data, col_val, col_uncert)
    - -

    Arguments

    - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    col_val

    a single column name that contains the base values.

    col_uncert

    a single column name that contains the uncertainty values.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Details

    - -

    This function could be somewhat replicated using cols_merge(), -however, cols_merge_uncert() employs the following specialized -semantics for NA handling:

    -
      -
    1. NAs in col_val result in missing values for the merged -column (e.g., NA + 0.1 = NA)

    2. -
    3. NAs in col_uncert (but not col_val) result in -base values only for the merged column (e.g., -12.0 + NA = 12.0)

    4. -
    5. NAs both col_val and col_uncert result in -missing values for the merged column (e.g., NA + NA = -NA)

    6. -
    -

    Any resulting NA values in the col_val column following the -merge operation can be easily formatted using the fmt_missing() -function.

    -

    This function is part of a set of three column-merging functions. The other -two are the general cols_merge() function and the specialized -cols_merge_range() function. These functions operate similarly, -where the second column specified is dropped from the output table. For all -of the cols_merge*() functions, column removal occurs late in the -rendering lifecycle so those secondary columns are still usable as column -references (e.g., inside expressions provided to `rows` in the fmt*() -functions).

    - -

    Figures

    - - -

    - -

    See also

    - - - - -

    Examples

    -
    # Use `exibble` to create a gt table, -# keeping only the `currency` and `num` -# columns; merge columns into one with -# a base value and uncertainty (after -# formatting the `num` column) -tab_1 <- - exibble %>% - dplyr::select(currency, num) %>% - dplyr::slice(1:7) %>% - gt() %>% - fmt_number( - columns = vars(num), - decimals = 3, - use_seps = FALSE - ) %>% - cols_merge_uncert( - col_val = vars(currency), - col_uncert = vars(num) - ) %>% - cols_label( - currency = "value + uncert.")
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/cols_move.html b/docs/reference/cols_move.html deleted file mode 100644 index 74cf9bbe76..0000000000 --- a/docs/reference/cols_move.html +++ /dev/null @@ -1,257 +0,0 @@ - - - - - - - - -Move one or more columns ā€” cols_move ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    On those occasions where you need to move columns this way or that way, we -can make use of the cols_move() function. While it's true that the -movement of columns can be done upstream of gt's API, it is much easier -and less error prone to use the function provided here. The movement -procedure here takes one or more specified columns (in the columns -argument) and places them to the right of a different column (the -after argument). The ordering of the columns to be moved is -preserved, as is the ordering of all other columns in the table.

    - -
    - -
    cols_move(data, columns, after)
    - -

    Arguments

    - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    columns

    the column names to move to as a group to a different -position. The order of the remaining columns will be preserved.

    after

    a column name used to anchor the insertion of the moved columns. -All of the moved columns will be placed to the right of this column.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Details

    - -

    The columns supplied in columns must all exist in the table and none -of them can be in the after argument. The after column must -also exist and only one column should be provided here. If you need to place -one or columns at the beginning of the column series, the -cols_move_to_start() function should be used. Similarly, if -those columns to move should be placed at the end of the column series then -use cols_move_to_end().

    - -

    Figures

    - - -

    - -

    See also

    - - - - -

    Examples

    -
    # Use `countrypops` to create a gt table; -# With the remaining columns, position -# `population` after `country_name` -tab_1 <- - countrypops %>% - dplyr::select(-contains("code")) %>% - dplyr::filter(country_name == "Mongolia") %>% - tail(5) %>% - gt() %>% - cols_move( - columns = vars(population), - after = vars(country_name) - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/cols_move_to_end.html b/docs/reference/cols_move_to_end.html deleted file mode 100644 index 8133b79df8..0000000000 --- a/docs/reference/cols_move_to_end.html +++ /dev/null @@ -1,260 +0,0 @@ - - - - - - - - -Move one or more columns to the end ā€” cols_move_to_end ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    It's possible to move a set of columns to the end of the column series, we -only need to specify which columns are to be moved. While this can be -done upstream of gt's API, this function makes to process much easier -and it's less error prone. The ordering of the columns that are moved -to the end is preserved (same with the ordering of all other columns in the -table).

    - -
    - -
    cols_move_to_end(data, columns)
    - -

    Arguments

    - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    columns

    the column names to move to the right-most side of the table. -The order in which columns are provided will be preserved (as is the case -with the remaining columns).

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Details

    - -

    The columns supplied in columns must all exist in the table. If you -need to place one or columns at the start of the column series, the -cols_move_to_start() function should be used. More control is -offered with the cols_move() function, where columns could be -placed after a specific column.

    - -

    Figures

    - - -

    -

    - -

    See also

    - - - - -

    Examples

    -
    # Use `countrypops` to create a gt table; -# With the remaining columns, move the -# `year` column to the end -tab_1 <- - countrypops %>% - dplyr::select(-contains("code")) %>% - dplyr::filter(country_name == "Mongolia") %>% - tail(5) %>% - gt() %>% - cols_move_to_end( - columns = vars(year) - ) - -# Use `countrypops` to create a gt table; -# With the remaining columns, move `year` -# and `country_name` to the end -tab_2 <- - countrypops %>% - dplyr::select(-contains("code")) %>% - dplyr::filter(country_name == "Mongolia") %>% - tail(5) %>% - gt() %>% - cols_move_to_end( - columns = vars(year, country_name) - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/cols_move_to_start.html b/docs/reference/cols_move_to_start.html deleted file mode 100644 index 7b01a4bd6a..0000000000 --- a/docs/reference/cols_move_to_start.html +++ /dev/null @@ -1,259 +0,0 @@ - - - - - - - - -Move one or more columns to the start ā€” cols_move_to_start ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    We can easily move set of columns to the beginning of the column series and -we only need to specify which columns. It's possible to do this -upstream of gt's API, however, it is easier with this function and it -presents less possibility for error. The ordering of the columns that -are moved to the start is preserved (same with the ordering of all other -columns in the table).

    - -
    - -
    cols_move_to_start(data, columns)
    - -

    Arguments

    - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    columns

    the column names to move to the left-most side of the table. -The order in which columns are provided will be preserved (as is the case -with the remaining columns).

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Details

    - -

    The columns supplied in columns must all exist in the table. If you -need to place one or columns at the end of the column series, the -cols_move_to_end() function should be used. More control is -offered with the cols_move() function, where columns could be -placed after a specific column.

    - -

    Figures

    - - -

    -

    - -

    See also

    - - - - -

    Examples

    -
    # Use `countrypops` to create a gt table; -# With the remaining columns, move the -# `year` column to the start -tab_1 <- - countrypops %>% - dplyr::select(-contains("code")) %>% - dplyr::filter(country_name == "Mongolia") %>% - tail(5) %>% - gt() %>% - cols_move_to_start( - columns = vars(year) - ) - -# Use `countrypops` to create a gt table; -# With the remaining columns, move `year` -# and `population` to the start -tab_2 <- - countrypops %>% - dplyr::select(-contains("code")) %>% - dplyr::filter(country_name == "Mongolia") %>% - tail(5) %>% - gt() %>% - cols_move_to_start( - columns = vars(year, population) - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/cols_split_delim.html b/docs/reference/cols_split_delim.html deleted file mode 100644 index 35905eed5a..0000000000 --- a/docs/reference/cols_split_delim.html +++ /dev/null @@ -1,253 +0,0 @@ - - - - - - - - -Create group names and column labels via delimited names ā€” cols_split_delim ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    This function will split selected delimited column names such that the first -components (LHS) are promoted to being spanner column labels, and the -secondary components (RHS) will become the column labels. Please note that -reference to individual columns must continue to be the column names from the -input table data (which are unique by necessity).

    - -
    - -
    cols_split_delim(data, delim, columns = NULL)
    - -

    Arguments

    - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    delim

    the delimiter to use to split an input column name. The -delimiter supplied will be autoescaped for the internal splitting -procedure. The first component of the split will become the group name and -the second component will be the column label.

    columns

    an optional vector of column names that this operation should -be limited to. The default is to consider all columns in the table.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Details

    - -

    If we look to the column names in the iris dataset as an example of -how cols_split_delim() might be useful, we find the names -Sepal.Length, Sepal.Width, Petal.Length, -Petal.Width. From this naming system, it's easy to see that the -Sepal and Petal can group together the repeated common -Length and Width values. In your own datasets, we can avoid a -lengthy relabeling with cols_label() if column names can be -fashioned beforehand to contain both the spanner column label and the column -label. An additional advantage is that the column names in the input table -data remain unique even though there may eventually be repeated column labels -in the rendered output table).

    - -

    Figures

    - - -

    - -

    See also

    - - - - -

    Examples

    -
    # Use `iris` to create a gt table; split -# any columns that are dot-separated -# between column spanner labels (first -# part) and column labels (second part) -tab_1 <- - iris %>% - dplyr::group_by(Species) %>% - dplyr::slice(1:4) %>% - gt() %>% - cols_split_delim(delim = ".")
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/countrypops.html b/docs/reference/countrypops.html deleted file mode 100644 index 5568899e88..0000000000 --- a/docs/reference/countrypops.html +++ /dev/null @@ -1,211 +0,0 @@ - - - - - - - - -Yearly populations of countries from 1960 to 2017 ā€” countrypops ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    A dataset that presents yearly, total populations of countries. Total -population is based on counts of all residents regardless of legal status or -citizenship. Country identifiers include the English-language country names, -and the 2- and 3-letter ISO 3166-1 country codes. Each row contains a -population value for a given year (from 1960 to 2017). Any -NA values for populations indicate the non-existence of the -country during that year.

    - -
    - -
    countrypops
    - -

    Format

    - -

    A tibble with 12470 rows and 5 variables:

    -
    country_name

    Name of the country

    -
    country_code_2

    The 2-letter ISO 3166-1 country code

    -
    country_code_3

    The 3-letter ISO 3166-1 country code

    -
    year

    The year for the population estimate

    -
    population

    The population estimate, midway through the year

    -
    - -

    Source

    - -

    https://data.worldbank.org/indicator/SP.POP.TOTL

    - - -

    Examples

    -
    # Here is a glimpse at the data -# available in `countrypops` -dplyr::glimpse(countrypops)
    #> Observations: 12,470 -#> Variables: 5 -#> $ country_name <chr> "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", ā€¦ -#> $ country_code_2 <chr> "AW", "AW", "AW", "AW", "AW", "AW", "AW", "AW", "AW", ā€¦ -#> $ country_code_3 <chr> "ABW", "ABW", "ABW", "ABW", "ABW", "ABW", "ABW", "ABW"ā€¦ -#> $ year <int> 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, ā€¦ -#> $ population <int> 54211, 55438, 56225, 56695, 57032, 57360, 57715, 58055ā€¦
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/data_color.html b/docs/reference/data_color.html deleted file mode 100644 index fe492e54d2..0000000000 --- a/docs/reference/data_color.html +++ /dev/null @@ -1,344 +0,0 @@ - - - - - - - - -Set data cell colors using a palette or a color function ā€” data_color ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    It's possible to add color to data cells according to their values. The -data_color() function colors all rows of any columns supplied. -There are two ways to define how cells are colored: (1) through the use of a -supplied color palette, and (2) through use of a color mapping function -available from the scales package. The first method colorizes cell -data according to whether values are character or numeric. The second method -provides more control over how cells are colored since we provide an explicit -color function and thus other requirements such as bin counts, cut points, or -a numeric domain. Finally, we can choose whether to apply the cell-specific -colors to either the cell background or the cell text.

    - -
    - -
    data_color(data, columns, colors, alpha = NULL, apply_to = "bkgd",
    -  autocolor_text = TRUE)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    columns

    the columns wherein changes to cell data colors should occur.

    colors

    either a color mapping function from the scales package -or a vector of colors to use for each distinct value or level in each of -the provided columns. The color mapping functions are: -scales::col_quantile(), scales::col_bin(), -scales::col_numeric(), and scales::col_factor(). If providing -a vector of colors as a palette, each color value provided must either be a -color name (in the set of colors provided by grDevices::colors()) or -a hexadecimal string in the form of "#RRGGBB" or "#RRGGBBAA".

    alpha

    an optional, fixed alpha transparency value that will be applied -to all of the colors provided if they are provided as a vector of -colors. If using a colorizing helper function for colors then this -option is ignored (each of the colorizing helper functions has its own -alpha argument).

    apply_to

    which style element should the colors be applied to? Options -include the cell background (the default, given as bkgd) or the cell -text (text).

    autocolor_text

    an option to let gt modify the coloring of text -within cells undergoing background coloring. This will in some cases yield -more optimal text-to-background color contrast. By default, this is set to -TRUE.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Details

    - -

    The col_*() functions from the scales package can be used in the -colors argument. These functions map data values (numeric or -factor/character) to colors according to the provided palette.

    -
      -
    • col_numeric(): provides a simple linear mapping -from continuous numeric data to an interpolated palette.

    • -
    • col_bin(): provides a mapping of continuous -numeric data to value-based bins. This internally uses the -cut() function.

    • -
    • col_quantile(): provides a mapping of continuous -numeric data to quantiles. This internally uses the -quantile() function.

    • -
    • col_factor(): provides a mapping of factors to -colors. If the palette is discrete and has a different number of colors than -the number of factors, interpolation is used.

    • -
    -

    By default, gt will choose the ideal text color (for maximal contrast) -when colorizing the background of data cells. This option can be disabled by -setting autocolor_text to FALSE.

    -

    Choosing the right color palette can often be difficult because it's both -hard to discover suitable palettes and then obtain the vector of colors. To -make this process easier we can elect to use the paletteer package, -which makes a wide range of palettes from various R packages readily -available. The info_paletteer() information table allows us to -easily inspect all of the discrete color palettes available in -paletteer. We only then need to specify the package and -palette when calling the paletteer::paletteer_d() function, -and, we get the palette as a vector of hexadecimal colors.

    - -

    Figures

    - - -

    -

    - -

    See also

    - - - - -

    Examples

    -
    # library(paletteer) - -# Use `countrypops` to create a gt table; -# Apply a color scale to the `population` -# column with `scales::col_numeric`, -# four supplied colors, and a domain -tab_1 <- - countrypops %>% - dplyr::filter(country_name == "Mongolia") %>% - dplyr::select(-contains("code")) %>% - tail(10) %>% - gt() %>% - data_color( - columns = vars(population), - colors = scales::col_numeric( - palette = c( - "red", "orange", "green", "blue"), - domain = c(0.2E7, 0.4E7)) - ) - -# Use `pizzaplace` to create a gt table; -# Apply colors from the `red_material` -# palette (in the `ggsci` pkg but -# more easily gotten from the `paletteer` -# package, info at `info_paletteer()`) to -# to `sold` and `income` columns; setting -# the `domain` of `scales::col_numeric()` -# to `NULL` will use the bounds of the -# available data as the domain -tab_2 <- - pizzaplace %>% - dplyr::filter( - type %in% c("chicken", "supreme")) %>% - dplyr::group_by(type, size) %>% - dplyr::summarize( - sold = n(), - income = sum(price) - ) %>% - gt(rowname_col = "size") %>% - data_color( - columns = vars(sold, income), - colors = scales::col_numeric( - palette = paletteer::paletteer_d( - package = "ggsci", - palette = "red_material" - ), - domain = NULL) - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/escape_latex.html b/docs/reference/escape_latex.html deleted file mode 100644 index ec0b631415..0000000000 --- a/docs/reference/escape_latex.html +++ /dev/null @@ -1,192 +0,0 @@ - - - - - - - - -Perform LaTeX escaping ā€” escape_latex ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Text may contain several characters with special meanings in LaTeX. This -function will transform a character vector so that it is safe to use within -LaTeX tables.

    - -
    - -
    escape_latex(text)
    - -

    Arguments

    - - - - - - -
    text

    a character vector containing the text that is to be -LaTeX-escaped.

    - -

    See also

    - -

    Other helper functions: cells_styles, - gt_latex_dependencies, html, - md, pct, px

    - - -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/exibble.html b/docs/reference/exibble.html deleted file mode 100644 index 249a8aea72..0000000000 --- a/docs/reference/exibble.html +++ /dev/null @@ -1,223 +0,0 @@ - - - - - - - - -A toy example tibble for testing with gt: exibble ā€” exibble ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    This tibble contains data of a few different classes, which makes it -well-suited for quick experimentation with the functions in this package. It -contains only eight rows with numeric, character, and factor columns. The -last 4 rows contain NA values in the majority of this tibble's columns -(1 missing value per column). The date, time, and -datetime columns are character-based dates/times in the familiar ISO -8601 format. The row and group columns provide for unique -rownames and two groups (grp_a and grp_b) for experimenting -with the gt() function's rowname_col and -groupname_col arguments.

    - -
    - -
    exibble
    - -

    Format

    - -

    A tibble with 8 rows and 9 variables:

    -
    num

    a numeric column ordered with increasingly larger values

    -
    char

    a character column composed of names of fruits from a to - h

    -
    fctr

    a factor column with numbers from 1 to 8, written out

    -
    date, time, datetime

    character columns with dates, times, and - datetimes

    -
    currency

    a numeric column that is useful for testing currency-based - formatting

    -
    row

    a character column in the format row_X which can be - useful for testing with row captions in a table stub

    -
    group

    a character column with four grp_a values and four - grp_b values which can be useful for testing tables that contain - row groups

    -
    - - -

    Examples

    -
    # Here is a glimpse at the data -# available in `exibble` -dplyr::glimpse(exibble)
    #> Observations: 8 -#> Variables: 9 -#> $ num <dbl> 1.111e-01, 2.222e+00, 3.333e+01, 4.444e+02, 5.550e+03, NA, 7ā€¦ -#> $ char <chr> "apricot", "banana", "coconut", "durian", NA, "fig", "grapefā€¦ -#> $ fctr <fct> one, two, three, four, five, six, seven, eight -#> $ date <chr> "2015-01-15", "2015-02-15", "2015-03-15", "2015-04-15", "201ā€¦ -#> $ time <chr> "13:35", "14:40", "15:45", "16:50", "17:55", NA, "19:10", "2ā€¦ -#> $ datetime <chr> "2018-01-01 02:22", "2018-02-02 14:33", "2018-03-03 03:44", ā€¦ -#> $ currency <dbl> 49.950, 17.950, 1.390, 65100.000, 1325.810, 13.255, NA, 0.440 -#> $ row <chr> "row_1", "row_2", "row_3", "row_4", "row_5", "row_6", "row_7ā€¦ -#> $ group <chr> "grp_a", "grp_a", "grp_a", "grp_a", "grp_b", "grp_b", "grp_bā€¦
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/extract_summary.html b/docs/reference/extract_summary.html deleted file mode 100644 index 21531cdbb7..0000000000 --- a/docs/reference/extract_summary.html +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - - - -Extract a summary list from a <span class="pkg">gt</span> object ā€” extract_summary ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -gt object ā€” extract_summary" /> - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Get a list of summary row data frames from a gt_tbl object where -summary rows were added via the summary_rows() function. The -output data frames contain the groupname and rowname columns, -whereby rowname contains descriptive stub labels for the summary rows.

    - -
    - -
    extract_summary(data)
    - -

    Arguments

    - - - - - - -
    data

    a table object that is created using the gt() -function.

    - -

    Value

    - -

    a list of data frames containing summary data.

    - -

    Figures

    - - -

    - -

    See also

    - -

    Other table export functions: as_latex, - as_raw_html, as_rtf

    - - -

    Examples

    -
    # Use `sp500` to create a gt table with -# row groups; create summary rows by row -# group (`min`, `max`, `avg`) and then -# extract the summary rows as a list -# object -summary_extracted <- - sp500 %>% - dplyr::filter( - date >= "2015-01-05" & - date <="2015-01-30" - ) %>% - dplyr::arrange(date) %>% - dplyr::mutate( - week = paste0( - "W", strftime(date, format = "%V")) - ) %>% - dplyr::select(-adj_close, -volume) %>% - gt( - rowname_col = "date", - groupname_col = "week" - ) %>% - summary_rows( - groups = TRUE, - columns = vars(open, high, low, close), - fns = list( - min = ~min(.), - max = ~max(.), - avg = ~mean(.)), - formatter = fmt_number, - use_seps = FALSE - ) %>% - extract_summary() - -# Use the summary list to make a new -# gt table; the key thing is to use -# `dplyr::bind_rows()` and then pass the -# tibble to `gt()` (the `groupname` and -# `rowname` magic column names create -# row groups and a stub) -tab_1 <- - summary_extracted %>% - dplyr::bind_rows() %>% - gt()
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/figures/cc_lines_exported.svg b/docs/reference/figures/cc_lines_exported.svg deleted file mode 100644 index 9731876540..0000000000 --- a/docs/reference/figures/cc_lines_exported.svg +++ /dev/null @@ -1,2794 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Exported functions from the - - - -gt - - - - package - - - -As of - - - -2018-12-19 - - - -Function -CC -Lines -Code -Comment -Blank -roxygen -Total - - - -adjust_luminance - - - -2 -20 -11 -12 -7 - - - -50 - - - -as_latex - - - -2 -55 -20 -19 -25 - - - -119 - - - -as_raw_html - - - -2 -10 -2 -4 -26 - - - -42 - - - -as_rtf - - - -44 -210 -86 -99 -17 - - - -412 - - - -cells_column_labels - - - -11 -19 -5 -6 -3 - - - -33 - - - -cells_data - - - -1 -10 -6 -4 -3 - - - -23 - - - -cells_group - - - -1 -6 -3 -4 -3 - - - -16 - - - -cells_stub - - - -2 -9 -3 -5 -3 - - - -20 - - - -cells_styles - - - -22 -62 -0 -17 -35 - - - -114 - - - -cells_summary - - - -1 -14 -4 -4 -3 - - - -25 - - - -cells_title - - - -1 -6 -4 -4 -3 - - - -17 - - - -cols_align - - - -2 -32 -6 -10 -35 - - - -83 - - - -cols_hide - - - -4 -14 -4 -7 -47 - - - -72 - - - -cols_label - - - -8 -25 -9 -11 -47 - - - -92 - - - -cols_merge - - - -8 -32 -3 -11 -41 - - - -87 - - - -cols_merge_range - - - -8 -32 -4 -12 -30 - - - -78 - - - -cols_merge_uncert - - - -8 -32 -4 -12 -34 - - - -82 - - - -cols_move - - - -10 -40 -12 -16 -28 - - - -96 - - - -cols_move_to_end - - - -5 -19 -7 -9 -41 - - - -76 - - - -cols_move_to_start - - - -5 -18 -6 -8 -41 - - - -73 - - - -cols_split_delim - - - -6 -26 -3 -11 -32 - - - -72 - - - -data_color - - - -16 -67 -17 -28 -83 - - - -195 - - - -escape_latex - - - -1 -6 -1 -1 -9 - - - -17 - - - -extract_summary - - - -2 -33 -27 -25 -59 - - - -144 - - - -fmt - - - -2 -26 -16 -13 -55 - - - -110 - - - -fmt_currency - - - -18 -125 -34 -31 -80 - - - -270 - - - -fmt_date - - - -1 -19 -4 -4 -88 - - - -115 - - - -fmt_datetime - - - -1 -23 -6 -6 -78 - - - -113 - - - -fmt_missing - - - -3 -24 -3 -4 -41 - - - -72 - - - -fmt_number - - - -9 -48 -13 -10 -103 - - - -174 - - - -fmt_passthrough - - - -3 -33 -6 -10 -48 - - - -97 - - - -fmt_percent - - - -12 -86 -20 -20 -55 - - - -181 - - - -fmt_scientific - - - -9 -65 -11 -15 -51 - - - -142 - - - -fmt_time - - - -1 -19 -4 -4 -78 - - - -105 - - - -ggplot_image - - - -2 -21 -1 -6 -38 - - - -66 - - - -gt - - - -6 -85 -53 -38 -68 - - - -244 - - - -gt_output - - - -1 -4 -0 -2 -6 - - - -12 - - - -gt_preview - - - -8 -62 -23 -22 -41 - - - -148 - - - -html - - - -1 -3 -0 -1 -23 - - - -27 - - - -info_date_style - - - -1 -29 -0 -1 -4 - - - -34 - - - -info_time_style - - - -1 -17 -0 -1 -4 - - - -22 - - - -local_image - - - -2 -13 -5 -4 -17 - - - -39 - - - -md - - - -1 -4 -1 -1 -21 - - - -27 - - - -pct - - - -2 -6 -0 -2 -6 - - - -14 - - - -px - - - -2 -6 -0 -2 -6 - - - -14 - - - -render_gt - - - -3 -26 -0 -7 -12 - - - -45 - - - -row_group_order - - - -6 -29 -10 -14 -39 - - - -92 - - - -summary_rows - - - -7 -41 -1 -8 -73 - - - -123 - - - -tab_footnote - - - -3 -9 -3 -3 -52 - - - -67 - - - -tab_header - - - -2 -12 -1 -3 -28 - - - -44 - - - -tab_options - - - -61 -259 -44 -106 -155 - - - -564 - - - -tab_row_group - - - -6 -38 -11 -17 -65 - - - -131 - - - -tab_source_note - - - -2 -12 -0 -5 -26 - - - -43 - - - -tab_spanner - - - -6 -19 -4 -7 -34 - - - -64 - - - -tab_stubhead_label - - - -1 -6 -0 -2 -25 - - - -33 - - - -tab_style - - - -3 -9 -3 -3 -77 - - - -92 - - - -test_image - - - -2 -8 -0 -2 -8 - - - -18 - - - -text_transform - - - -3 -9 -3 -3 -60 - - - -75 - - - -web_image - - - -2 -8 -0 -2 -17 - - - -27 - - - diff --git a/docs/reference/figures/gt_datasets.svg b/docs/reference/figures/gt_datasets.svg deleted file mode 100644 index 3d029065c2..0000000000 --- a/docs/reference/figures/gt_datasets.svg +++ /dev/null @@ -1,511 +0,0 @@ - - - - included_gt_datasets - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/reference/figures/gt_functions.svg b/docs/reference/figures/gt_functions.svg deleted file mode 100644 index 4ad30932e2..0000000000 --- a/docs/reference/figures/gt_functions.svg +++ /dev/null @@ -1,333 +0,0 @@ - - - - gt_functions - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/reference/figures/gt_hex_logo.svg b/docs/reference/figures/gt_hex_logo.svg deleted file mode 100644 index 97b7177bac..0000000000 --- a/docs/reference/figures/gt_hex_logo.svg +++ /dev/null @@ -1,324 +0,0 @@ - - - - gt_hex_logo - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/reference/figures/gt_parts_of_a_table.svg b/docs/reference/figures/gt_parts_of_a_table.svg deleted file mode 100644 index 147e4a427b..0000000000 --- a/docs/reference/figures/gt_parts_of_a_table.svg +++ /dev/null @@ -1,146 +0,0 @@ - - - - gt_parts_of_a_table_svg - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SVG Version - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/reference/figures/gt_sp500_table.svg b/docs/reference/figures/gt_sp500_table.svg deleted file mode 100644 index 9f07f05b0a..0000000000 --- a/docs/reference/figures/gt_sp500_table.svg +++ /dev/null @@ -1,1309 +0,0 @@ - - - - sp500_example_table - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/reference/figures/gt_tables.png b/docs/reference/figures/gt_tables.png deleted file mode 100644 index 4e4192033f..0000000000 Binary files a/docs/reference/figures/gt_tables.png and /dev/null differ diff --git a/docs/reference/figures/gt_workflow_diagram.svg b/docs/reference/figures/gt_workflow_diagram.svg deleted file mode 100644 index 591be8565a..0000000000 --- a/docs/reference/figures/gt_workflow_diagram.svg +++ /dev/null @@ -1,151 +0,0 @@ - - - - gt_workflow_diagram - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/reference/figures/logo.svg b/docs/reference/figures/logo.svg deleted file mode 100644 index 97b7177bac..0000000000 --- a/docs/reference/figures/logo.svg +++ /dev/null @@ -1,324 +0,0 @@ - - - - gt_hex_logo - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/reference/figures/man_adjust_luminance_1.svg b/docs/reference/figures/man_adjust_luminance_1.svg deleted file mode 100644 index 3f3cb78df7..0000000000 --- a/docs/reference/figures/man_adjust_luminance_1.svg +++ /dev/null @@ -1,243 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -a -b -c -1 -1 -1 -2 -2 -2 -3 -3 -3 -4 -4 -4 -5 -5 -5 -6 -6 -6 -7 -7 -7 -8 -8 -8 - - - diff --git a/docs/reference/figures/man_cols_align_1.svg b/docs/reference/figures/man_cols_align_1.svg deleted file mode 100644 index 374ad7a038..0000000000 --- a/docs/reference/figures/man_cols_align_1.svg +++ /dev/null @@ -1,92 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -country_name -year -population -Mongolia -2013 -2869107 -Mongolia -2014 -2923896 -Mongolia -2015 -2976877 -Mongolia -2016 -3027398 -Mongolia -2017 -3075647 - - - diff --git a/docs/reference/figures/man_cols_hide_1.svg b/docs/reference/figures/man_cols_hide_1.svg deleted file mode 100644 index e2b6ee005f..0000000000 --- a/docs/reference/figures/man_cols_hide_1.svg +++ /dev/null @@ -1,92 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -country_name -year -population -Mongolia -2013 -2869107 -Mongolia -2014 -2923896 -Mongolia -2015 -2976877 -Mongolia -2016 -3027398 -Mongolia -2017 -3075647 - - - diff --git a/docs/reference/figures/man_cols_hide_2.svg b/docs/reference/figures/man_cols_hide_2.svg deleted file mode 100644 index f46174f21b..0000000000 --- a/docs/reference/figures/man_cols_hide_2.svg +++ /dev/null @@ -1,126 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -country_name -country_code_2 -year -Mongolia -MN -2013 -Mongolia -MN -2014 -Mongolia -MN -2015 -Mongolia -MN -2016 - - - -1 - - - -Mongolia -MN -2017 - - - -1 - - - -1 - - - - Population above 3,000,000. - - - diff --git a/docs/reference/figures/man_cols_label_1.svg b/docs/reference/figures/man_cols_label_1.svg deleted file mode 100644 index ccccb1d6d6..0000000000 --- a/docs/reference/figures/man_cols_label_1.svg +++ /dev/null @@ -1,92 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Name -Year -Population -Mongolia -2013 -2869107 -Mongolia -2014 -2923896 -Mongolia -2015 -2976877 -Mongolia -2016 -3027398 -Mongolia -2017 -3075647 - - - diff --git a/docs/reference/figures/man_cols_label_2.svg b/docs/reference/figures/man_cols_label_2.svg deleted file mode 100644 index 6b22eca264..0000000000 --- a/docs/reference/figures/man_cols_label_2.svg +++ /dev/null @@ -1,97 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Name -Year -Population - - - -Mongolia -2013 -2869107 -Mongolia -2014 -2923896 -Mongolia -2015 -2976877 -Mongolia -2016 -3027398 -Mongolia -2017 -3075647 - - - diff --git a/docs/reference/figures/man_cols_merge_1.svg b/docs/reference/figures/man_cols_merge_1.svg deleted file mode 100644 index 6279dff361..0000000000 --- a/docs/reference/figures/man_cols_merge_1.svg +++ /dev/null @@ -1,101 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -date -open/close -low/high -2015-10-21 -2033.47ā€”2018.94 -2017.22ā€”2037.97 -2015-10-20 -2033.13ā€”2030.77 -2026.61ā€”2039.12 -2015-10-19 -2031.73ā€”2033.66 -2022.31ā€”2034.45 -2015-10-16 -2024.37ā€”2033.11 -2020.46ā€”2033.54 -2015-10-15 -1996.47ā€”2023.86 -1996.47ā€”2024.15 -2015-10-14 -2003.66ā€”1994.24 -1990.73ā€”2009.56 - - - diff --git a/docs/reference/figures/man_cols_merge_range_1.svg b/docs/reference/figures/man_cols_merge_range_1.svg deleted file mode 100644 index 33a6172e0a..0000000000 --- a/docs/reference/figures/man_cols_merge_range_1.svg +++ /dev/null @@ -1,99 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -model - - - -MPG - - - -GT -11 ā€” 18 -458 Speciale -13 ā€” 17 -458 Spider -13 ā€” 17 -458 Italia -13 ā€” 17 -488 GTB -15 ā€” 22 -California -16 ā€” 23 -GTC4Lusso -12 ā€” 17 -FF -11 ā€” 16 - - - diff --git a/docs/reference/figures/man_cols_merge_uncert_1.svg b/docs/reference/figures/man_cols_merge_uncert_1.svg deleted file mode 100644 index 951c1f757a..0000000000 --- a/docs/reference/figures/man_cols_merge_uncert_1.svg +++ /dev/null @@ -1,59 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - -value + uncert. -49.950 Ā± 0.111 -17.950 Ā± 2.222 -1.390 Ā± 33.330 -65100.000 Ā± 444.400 -1325.810 Ā± 5550.000 -13.255 -NA - - - diff --git a/docs/reference/figures/man_cols_move_1.svg b/docs/reference/figures/man_cols_move_1.svg deleted file mode 100644 index 9ccd700b9b..0000000000 --- a/docs/reference/figures/man_cols_move_1.svg +++ /dev/null @@ -1,92 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -country_name -population -year -Mongolia -2869107 -2013 -Mongolia -2923896 -2014 -Mongolia -2976877 -2015 -Mongolia -3027398 -2016 -Mongolia -3075647 -2017 - - - diff --git a/docs/reference/figures/man_cols_move_to_end_1.svg b/docs/reference/figures/man_cols_move_to_end_1.svg deleted file mode 100644 index 9ccd700b9b..0000000000 --- a/docs/reference/figures/man_cols_move_to_end_1.svg +++ /dev/null @@ -1,92 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -country_name -population -year -Mongolia -2869107 -2013 -Mongolia -2923896 -2014 -Mongolia -2976877 -2015 -Mongolia -3027398 -2016 -Mongolia -3075647 -2017 - - - diff --git a/docs/reference/figures/man_cols_move_to_end_2.svg b/docs/reference/figures/man_cols_move_to_end_2.svg deleted file mode 100644 index 1c22681734..0000000000 --- a/docs/reference/figures/man_cols_move_to_end_2.svg +++ /dev/null @@ -1,92 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -population -year -country_name -2869107 -2013 -Mongolia -2923896 -2014 -Mongolia -2976877 -2015 -Mongolia -3027398 -2016 -Mongolia -3075647 -2017 -Mongolia - - - diff --git a/docs/reference/figures/man_cols_move_to_start_1.svg b/docs/reference/figures/man_cols_move_to_start_1.svg deleted file mode 100644 index e2b6ee005f..0000000000 --- a/docs/reference/figures/man_cols_move_to_start_1.svg +++ /dev/null @@ -1,92 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -country_name -year -population -Mongolia -2013 -2869107 -Mongolia -2014 -2923896 -Mongolia -2015 -2976877 -Mongolia -2016 -3027398 -Mongolia -2017 -3075647 - - - diff --git a/docs/reference/figures/man_cols_move_to_start_2.svg b/docs/reference/figures/man_cols_move_to_start_2.svg deleted file mode 100644 index 1a176c201d..0000000000 --- a/docs/reference/figures/man_cols_move_to_start_2.svg +++ /dev/null @@ -1,92 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -year -population -country_name -2013 -2869107 -Mongolia -2014 -2923896 -Mongolia -2015 -2976877 -Mongolia -2016 -3027398 -Mongolia -2017 -3075647 -Mongolia - - - diff --git a/docs/reference/figures/man_cols_split_delim_1.svg b/docs/reference/figures/man_cols_split_delim_1.svg deleted file mode 100644 index 893359e17f..0000000000 --- a/docs/reference/figures/man_cols_split_delim_1.svg +++ /dev/null @@ -1,252 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Sepal -Petal -Length -Width -Length -Width -setosa -5.1 -3.5 -1.4 -0.2 -4.9 -3.0 -1.4 -0.2 -4.7 -3.2 -1.3 -0.2 -4.6 -3.1 -1.5 -0.2 -versicolor -7.0 -3.2 -4.7 -1.4 -6.4 -3.2 -4.5 -1.5 -6.9 -3.1 -4.9 -1.5 -5.5 -2.3 -4.0 -1.3 -virginica -6.3 -3.3 -6.0 -2.5 -5.8 -2.7 -5.1 -1.9 -7.1 -3.0 -5.9 -2.1 -6.3 -2.9 -5.6 -1.8 - - - diff --git a/docs/reference/figures/man_data_color_1.svg b/docs/reference/figures/man_data_color_1.svg deleted file mode 100644 index b36b2b85d8..0000000000 --- a/docs/reference/figures/man_data_color_1.svg +++ /dev/null @@ -1,211 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -country_name -year -population -Mongolia -2008 -2628131 -Mongolia -2009 -2668289 -Mongolia -2010 -2712650 -Mongolia -2011 -2761516 -Mongolia -2012 -2814226 -Mongolia -2013 -2869107 -Mongolia -2014 -2923896 -Mongolia -2015 -2976877 -Mongolia -2016 -3027398 -Mongolia -2017 -3075647 - - - diff --git a/docs/reference/figures/man_data_color_2.svg b/docs/reference/figures/man_data_color_2.svg deleted file mode 100644 index 87ad03c45f..0000000000 --- a/docs/reference/figures/man_data_color_2.svg +++ /dev/null @@ -1,206 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -sold -income -chicken -L -4932 -102339.0 -M -3894 -65224.5 -S -2224 -28356.0 -supreme -L -4564 -94258.5 -M -4046 -66475.0 -S -3377 -47463.5 - - - diff --git a/docs/reference/figures/man_extract_summary_1.svg b/docs/reference/figures/man_extract_summary_1.svg deleted file mode 100644 index ad0b342bda..0000000000 --- a/docs/reference/figures/man_extract_summary_1.svg +++ /dev/null @@ -1,464 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -open -high -low -close -W02 -min -2005.550 -2029.610 -1992.440 -2002.610 -max -2063.450 -2064.430 -2038.330 -2062.140 -avg -2035.240 -2048.562 -2016.854 -2031.208 -W03 -min -1992.250 -2018.400 -1988.120 -1992.670 -max -2046.130 -2056.930 -2022.580 -2028.260 -avg -2020.422 -2033.288 -1999.772 -2014.930 -W04 -min -2020.190 -2028.940 -2004.490 -2022.550 -max -2062.980 -2064.620 -2050.540 -2063.150 -avg -2034.557 -2048.707 -2023.362 -2042.410 -W05 -min -2002.450 -2023.320 -1989.180 -1994.990 -max -2050.420 -2057.620 -2040.970 -2057.090 -avg -2030.484 -2039.186 -2008.986 -2021.008 - - - diff --git a/docs/reference/figures/man_fmt_1.svg b/docs/reference/figures/man_fmt_1.svg deleted file mode 100644 index 983d6a0023..0000000000 --- a/docs/reference/figures/man_fmt_1.svg +++ /dev/null @@ -1,224 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -num -char -fctr -date -time -datetime -currency -'111.1' -apricot -one -2015-01-15 -13:35 -2018-01-01 02:22 -49.950 -'2222' -banana -two -2015-02-15 -14:40 -2018-02-02 14:33 -17.950 -'33330' -coconut -three -2015-03-15 -15:45 -2018-03-03 03:44 -1.390 -'444400' -durian -four -2015-04-15 -16:50 -2018-04-04 15:55 -65100.000 -'5550000' -NA -five -2015-05-15 -17:55 -2018-05-05 04:00 -1325.810 -'NA' -fig -six -2015-06-15 -NA -2018-06-06 16:11 -13.255 -'7.77e+08' -grapefruit -seven -NA -19:10 -2018-07-07 05:22 -NA -'8.88e+09' -honeydew -eight -2015-08-15 -20:20 -NA -0.440 - - - diff --git a/docs/reference/figures/man_fmt_currency_1.svg b/docs/reference/figures/man_fmt_currency_1.svg deleted file mode 100644 index ec45fdf734..0000000000 --- a/docs/reference/figures/man_fmt_currency_1.svg +++ /dev/null @@ -1,278 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -num -char -fctr -date -time -datetime -currency -row -group -1.111e-01 -apricot -one -2015-01-15 -13:35 -2018-01-01 02:22 -ā‚¬49.95 -row_1 -grp_a -2.222e+00 -banana -two -2015-02-15 -14:40 -2018-02-02 14:33 -ā‚¬17.95 -row_2 -grp_a -3.333e+01 -coconut -three -2015-03-15 -15:45 -2018-03-03 03:44 -ā‚¬1.39 -row_3 -grp_a -4.444e+02 -durian -four -2015-04-15 -16:50 -2018-04-04 15:55 -ā‚¬65,100.00 -row_4 -grp_a -5.550e+03 -NA -five -2015-05-15 -17:55 -2018-05-05 04:00 -ā‚¬1,325.81 -row_5 -grp_b -NA -fig -six -2015-06-15 -NA -2018-06-06 16:11 -ā‚¬13.26 -row_6 -grp_b -7.770e+05 -grapefruit -seven -NA -19:10 -2018-07-07 05:22 -NA -row_7 -grp_b -8.880e+06 -honeydew -eight -2015-08-15 -20:20 -NA -ā‚¬0.44 -row_8 -grp_b - - - diff --git a/docs/reference/figures/man_fmt_currency_2.svg b/docs/reference/figures/man_fmt_currency_2.svg deleted file mode 100644 index b32303056d..0000000000 --- a/docs/reference/figures/man_fmt_currency_2.svg +++ /dev/null @@ -1,89 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -num -currency -Ā„0.11 -Ā£49.95 -Ā„2.22 -Ā£17.95 -Ā„33.33 -Ā£1.39 -Ā„444.40 -Ā£65,100.00 -Ā„5,550.00 -Ā£1,325.81 -NA -Ā£13.26 -Ā„777,000.00 -NA -Ā„8,880,000.00 -Ā£0.44 - - - diff --git a/docs/reference/figures/man_fmt_date_1.svg b/docs/reference/figures/man_fmt_date_1.svg deleted file mode 100644 index dc09532585..0000000000 --- a/docs/reference/figures/man_fmt_date_1.svg +++ /dev/null @@ -1,89 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -date -time -January 15, 2015 -13:35 -February 15, 2015 -14:40 -March 15, 2015 -15:45 -April 15, 2015 -16:50 -May 15, 2015 -17:55 -June 15, 2015 -NA -NA -19:10 -August 15, 2015 -20:20 - - - diff --git a/docs/reference/figures/man_fmt_date_2.svg b/docs/reference/figures/man_fmt_date_2.svg deleted file mode 100644 index a1629fd02e..0000000000 --- a/docs/reference/figures/man_fmt_date_2.svg +++ /dev/null @@ -1,89 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -date -time -15 Jan 2015 -13:35 -15 Feb 2015 -14:40 -15 Mar 2015 -15:45 -Apr 15, 2015 -16:50 -May 15, 2015 -17:55 -Jun 15, 2015 -NA -NA -19:10 -Aug 15, 2015 -20:20 - - - diff --git a/docs/reference/figures/man_fmt_datetime_1.svg b/docs/reference/figures/man_fmt_datetime_1.svg deleted file mode 100644 index dab0a33249..0000000000 --- a/docs/reference/figures/man_fmt_datetime_1.svg +++ /dev/null @@ -1,62 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - -datetime -January 1, 2018 2:22:00 AM -February 2, 2018 2:33:00 PM -March 3, 2018 3:44:00 AM -April 4, 2018 3:55:00 PM -May 5, 2018 4:00:00 AM -June 6, 2018 4:11:00 PM -July 7, 2018 5:22:00 AM -NA - - - diff --git a/docs/reference/figures/man_fmt_missing_1.svg b/docs/reference/figures/man_fmt_missing_1.svg deleted file mode 100644 index 4fb5cb7e8c..0000000000 --- a/docs/reference/figures/man_fmt_missing_1.svg +++ /dev/null @@ -1,224 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -num -char -fctr -date -time -datetime -currency -0.1111 -apricot -one -2015-01-15 -13:35 -2018-01-01 02:22 -49.95 -2.222 -banana -two -2015-02-15 -14:40 -2018-02-02 14:33 -17.95 -33.33 -coconut -three -2015-03-15 -15:45 -2018-03-03 03:44 -1.39 -444.4 -durian -four -2015-04-15 -16:50 -2018-04-04 15:55 -65100 -5550 -missing -five -2015-05-15 -17:55 -2018-05-05 04:00 -1325.81 -missing -fig -six -2015-06-15 -nothing -2018-06-06 16:11 -13.255 -777000 -grapefruit -seven -nothing -19:10 -2018-07-07 05:22 -nothing -8880000 -honeydew -eight -2015-08-15 -20:20 -nothing -0.44 - - - diff --git a/docs/reference/figures/man_fmt_number_1.svg b/docs/reference/figures/man_fmt_number_1.svg deleted file mode 100644 index 526f92a22c..0000000000 --- a/docs/reference/figures/man_fmt_number_1.svg +++ /dev/null @@ -1,278 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -num -char -fctr -date -time -datetime -currency -row -group -0.111 -apricot -one -2015-01-15 -13:35 -2018-01-01 02:22 -49.950 -row_1 -grp_a -2.222 -banana -two -2015-02-15 -14:40 -2018-02-02 14:33 -17.950 -row_2 -grp_a -33.330 -coconut -three -2015-03-15 -15:45 -2018-03-03 03:44 -1.390 -row_3 -grp_a -444.400 -durian -four -2015-04-15 -16:50 -2018-04-04 15:55 -65100.000 -row_4 -grp_a -5550.000 -NA -five -2015-05-15 -17:55 -2018-05-05 04:00 -1325.810 -row_5 -grp_b -NA -fig -six -2015-06-15 -NA -2018-06-06 16:11 -13.255 -row_6 -grp_b -777000.000 -grapefruit -seven -NA -19:10 -2018-07-07 05:22 -NA -row_7 -grp_b -8880000.000 -honeydew -eight -2015-08-15 -20:20 -NA -0.440 -row_8 -grp_b - - - diff --git a/docs/reference/figures/man_fmt_number_2.svg b/docs/reference/figures/man_fmt_number_2.svg deleted file mode 100644 index 821f06c607..0000000000 --- a/docs/reference/figures/man_fmt_number_2.svg +++ /dev/null @@ -1,278 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -num -char -fctr -date -time -datetime -currency -row -group -0.11 -apricot -one -2015-01-15 -13:35 -2018-01-01 02:22 -49.950 -row_1 -grp_a -2.22 -banana -two -2015-02-15 -14:40 -2018-02-02 14:33 -17.950 -row_2 -grp_a -33.33 -coconut -three -2015-03-15 -15:45 -2018-03-03 03:44 -1.390 -row_3 -grp_a -444.40 -durian -four -2015-04-15 -16:50 -2018-04-04 15:55 -65100.000 -row_4 -grp_a -5.5K -NA -five -2015-05-15 -17:55 -2018-05-05 04:00 -1325.810 -row_5 -grp_b -NA -fig -six -2015-06-15 -NA -2018-06-06 16:11 -13.255 -row_6 -grp_b -777.0K -grapefruit -seven -NA -19:10 -2018-07-07 05:22 -NA -row_7 -grp_b -8,880.0K -honeydew -eight -2015-08-15 -20:20 -NA -0.440 -row_8 -grp_b - - - diff --git a/docs/reference/figures/man_fmt_passthrough_1.svg b/docs/reference/figures/man_fmt_passthrough_1.svg deleted file mode 100644 index 7209409765..0000000000 --- a/docs/reference/figures/man_fmt_passthrough_1.svg +++ /dev/null @@ -1,62 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - -char -apricots -bananas -coconuts -durians -NA -figs -grapefruits -honeydews - - - diff --git a/docs/reference/figures/man_fmt_percent_1.svg b/docs/reference/figures/man_fmt_percent_1.svg deleted file mode 100644 index 493d4c1ec9..0000000000 --- a/docs/reference/figures/man_fmt_percent_1.svg +++ /dev/null @@ -1,278 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -num -char -fctr -date -time -datetime -currency -row -group -11.1% -apricot -one -2015-01-15 -13:35 -2018-01-01 02:22 -49.950 -row_1 -grp_a -222.2% -banana -two -2015-02-15 -14:40 -2018-02-02 14:33 -17.950 -row_2 -grp_a -3,333% -coconut -three -2015-03-15 -15:45 -2018-03-03 03:44 -1.390 -row_3 -grp_a -44,440% -durian -four -2015-04-15 -16:50 -2018-04-04 15:55 -65100.000 -row_4 -grp_a -555,000% -NA -five -2015-05-15 -17:55 -2018-05-05 04:00 -1325.810 -row_5 -grp_b -NA -fig -six -2015-06-15 -NA -2018-06-06 16:11 -13.255 -row_6 -grp_b -777000 -grapefruit -seven -NA -19:10 -2018-07-07 05:22 -NA -row_7 -grp_b -8880000 -honeydew -eight -2015-08-15 -20:20 -NA -0.440 -row_8 -grp_b - - - diff --git a/docs/reference/figures/man_fmt_scientific_1.svg b/docs/reference/figures/man_fmt_scientific_1.svg deleted file mode 100644 index 6341e3e3c2..0000000000 --- a/docs/reference/figures/man_fmt_scientific_1.svg +++ /dev/null @@ -1,314 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -num -char -fctr -date -time -datetime -currency -row -group -1.1 Ɨ 10 - - - --1 - - - -apricot -one -2015-01-15 -13:35 -2018-01-01 02:22 -49.950 -row_1 -grp_a -2.2 -banana -two -2015-02-15 -14:40 -2018-02-02 14:33 -17.950 -row_2 -grp_a -3.3 Ɨ 10 - - - -1 - - - -coconut -three -2015-03-15 -15:45 -2018-03-03 03:44 -1.390 -row_3 -grp_a -4.4 Ɨ 10 - - - -2 - - - -durian -four -2015-04-15 -16:50 -2018-04-04 15:55 -65100.000 -row_4 -grp_a -5.5K -NA -five -2015-05-15 -17:55 -2018-05-05 04:00 -1325.810 -row_5 -grp_b -NA -fig -six -2015-06-15 -NA -2018-06-06 16:11 -13.255 -row_6 -grp_b -777.0K -grapefruit -seven -NA -19:10 -2018-07-07 05:22 -NA -row_7 -grp_b -8,880.0K -honeydew -eight -2015-08-15 -20:20 -NA -0.440 -row_8 -grp_b - - - diff --git a/docs/reference/figures/man_fmt_time_1.svg b/docs/reference/figures/man_fmt_time_1.svg deleted file mode 100644 index b4076d4635..0000000000 --- a/docs/reference/figures/man_fmt_time_1.svg +++ /dev/null @@ -1,89 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -date -time -2015-01-15 -1:35:00 PM -2015-02-15 -2:40:00 PM -2015-03-15 -3:45:00 PM -2015-04-15 -4:50:00 PM -2015-05-15 -5:55:00 PM -2015-06-15 -NA -NA -7:10:00 PM -2015-08-15 -8:20:00 PM - - - diff --git a/docs/reference/figures/man_fmt_time_2.svg b/docs/reference/figures/man_fmt_time_2.svg deleted file mode 100644 index f132694967..0000000000 --- a/docs/reference/figures/man_fmt_time_2.svg +++ /dev/null @@ -1,89 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -date -time -2015-01-15 -1:35 PM -2015-02-15 -2:40 PM -2015-03-15 -3:45 PM -2015-04-15 -4:50:00 PM -2015-05-15 -5:55:00 PM -2015-06-15 -NA -NA -7:10:00 PM -2015-08-15 -8:20:00 PM - - - diff --git a/docs/reference/figures/man_ggplot_image_1.svg b/docs/reference/figures/man_ggplot_image_1.svg deleted file mode 100644 index 0c24b25e99..0000000000 --- a/docs/reference/figures/man_ggplot_image_1.svg +++ /dev/null @@ -1,52 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - -text -ggplot -Here is a ggplot: - - - - - - - diff --git a/docs/reference/figures/man_gt_1.svg b/docs/reference/figures/man_gt_1.svg deleted file mode 100644 index b04c2feb6b..0000000000 --- a/docs/reference/figures/man_gt_1.svg +++ /dev/null @@ -1,380 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -num -char -fctr -date -time -datetime -currency -grp_a -row_1 -1.111e-01 -apricot -one -2015-01-15 -13:35 -2018-01-01 02:22 -49.950 -row_2 -2.222e+00 -banana -two -2015-02-15 -14:40 -2018-02-02 14:33 -17.950 -row_3 -3.333e+01 -coconut -three -2015-03-15 -15:45 -2018-03-03 03:44 -1.390 -row_4 -4.444e+02 -durian -four -2015-04-15 -16:50 -2018-04-04 15:55 -65100.000 -grp_b -row_5 -5.550e+03 -NA -five -2015-05-15 -17:55 -2018-05-05 04:00 -1325.810 -row_6 -NA -fig -six -2015-06-15 -NA -2018-06-06 16:11 -13.255 -row_7 -7.770e+05 -grapefruit -seven -NA -19:10 -2018-07-07 05:22 -NA -row_8 -8.880e+06 -honeydew -eight -2015-08-15 -20:20 -NA -0.440 - - - diff --git a/docs/reference/figures/man_gt_2.svg b/docs/reference/figures/man_gt_2.svg deleted file mode 100644 index 073cf42c9a..0000000000 --- a/docs/reference/figures/man_gt_2.svg +++ /dev/null @@ -1,398 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Table Title - - - -Subtitle - - - -number -char -fctr -date -time -datetime -currency -grp_a -row_1 -0.11 -apricot -one -2015-01-15 -13:35 -2018-01-01 02:22 -49.950 -row_2 -2.22 -banana -two -2015-02-15 -14:40 -2018-02-02 14:33 -17.950 -row_3 -33.33 -coconut -three -2015-03-15 -15:45 -2018-03-03 03:44 -1.390 -row_4 -444.40 -durian -four -2015-04-15 -16:50 -2018-04-04 15:55 -65100.000 -grp_b -row_5 -5,550.00 -NA -five -2015-05-15 -17:55 -2018-05-05 04:00 -1325.810 -row_6 -NA -fig -six -2015-06-15 -NA -2018-06-06 16:11 -13.255 -row_7 -777,000.00 -grapefruit -seven -NA -19:10 -2018-07-07 05:22 -NA -row_8 -8,880,000.00 -honeydew -eight -2015-08-15 -20:20 -NA -0.440 - - - diff --git a/docs/reference/figures/man_gt_preview_1.svg b/docs/reference/figures/man_gt_preview_1.svg deleted file mode 100644 index 7990fe8527..0000000000 --- a/docs/reference/figures/man_gt_preview_1.svg +++ /dev/null @@ -1,313 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -mfr -model -year - - - -1 - - - -Ford -GT -2017 - - - -2 - - - -Ferrari -458 Speciale -2015 - - - -3 - - - -Ferrari -458 Spider -2015 - - - -4 - - - -Ferrari -458 Italia -2014 - - - -5 - - - -Ferrari -488 GTB -2016 - - - -6..46 - - - -47 - - - -Rolls-Royce -Wraith -2016 - - - diff --git a/docs/reference/figures/man_html_1.svg b/docs/reference/figures/man_html_1.svg deleted file mode 100644 index e26abb615b..0000000000 --- a/docs/reference/figures/man_html_1.svg +++ /dev/null @@ -1,100 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -HTML - - - -currency -char -49.950 -apricot -17.950 -banana -1.390 -coconut -65100.000 -durian -1325.810 -NA -13.255 -fig -NA -grapefruit -0.440 -honeydew - - - diff --git a/docs/reference/figures/man_info_currencies_1.svg b/docs/reference/figures/man_info_currencies_1.svg deleted file mode 100644 index ee9281ff08..0000000000 --- a/docs/reference/figures/man_info_currencies_1.svg +++ /dev/null @@ -1,174 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Currencies Supported in - - - -gt - - - -Currency codes and numbers are used in the - - - -fmt_currency() - - - - function - - - -Identifiers -Exp -Formatted Currency -Currency Name -Currency Code -Currency Number -Hong Kong dollar -HKD -344 -2 -HK$49.95 -Honduran lempira -HNL -340 -2 -L49.95 -Croatian kuna -HRK -191 -2 -kn49.95 -Haitian gourde -HTG -332 -2 -G49.95 -Hungarian forint -HUF -348 -2 -Ft49.95 - - - diff --git a/docs/reference/figures/man_info_currencies_2.svg b/docs/reference/figures/man_info_currencies_2.svg deleted file mode 100644 index 96112b7be7..0000000000 --- a/docs/reference/figures/man_info_currencies_2.svg +++ /dev/null @@ -1,162 +0,0 @@ - - - - man_info_currencies_2 - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ā‚« - - - - Currencies Supported in - gt - - - - - - - - - - - - - - - Currency Symbol - - - Formatted Currency - - - dollar - - - - euro - - - - pound - - - - yen - - - - franc - - - - lira - - - - peseta - - - - won - - - - sheqel - - - - dong - - - - kip - - - - tugrik - - - - drachma - - - - peso - - - - guarani - - - - austral - - - - hryvnia - - - - cedi - - - - rupee - - - - generic - - - - - - \ No newline at end of file diff --git a/docs/reference/figures/man_info_date_style_1.svg b/docs/reference/figures/man_info_date_style_1.svg deleted file mode 100644 index 0ba133b8a6..0000000000 --- a/docs/reference/figures/man_info_date_style_1.svg +++ /dev/null @@ -1,212 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Preset Date Formats - - - -Usable in the - - - -fmt_date() - - - - and - - - -fmt_datetime() - - - - functions - - - -Date Formats -Formatted Date -Number -Name -1 -iso -2000-02-29 -2 -wday_month_day_year -Tuesday, February 29, 2000 -3 -wd_m_day_year -Tue, Feb 29, 2000 -4 -wday_day_month_year -Tuesday 29 February 2000 -5 -month_day_year -February 29, 2000 -6 -m_day_year -Feb 29, 2000 -7 -day_m_year -29 Feb 2000 -8 -day_month_year -29 February 2000 -9 -day_month -29 February -10 -year -2000 -11 -month -February -12 -day -29 -13 -year.mn.day -2000/02/29 -14 -y.mn.day -0/02/29 - - - diff --git a/docs/reference/figures/man_info_paletteer_1.svg b/docs/reference/figures/man_info_paletteer_1.svg deleted file mode 100644 index 5c8f202fda..0000000000 --- a/docs/reference/figures/man_info_paletteer_1.svg +++ /dev/null @@ -1,1738 +0,0 @@ - - - - man_info_paletteer_1 - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Package and Palette Name - - - Color Count and Palette - - - - - ggthemes - - - - - calc - - - - 12 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - colorblind - - - - 8 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - economist_bg - - - - 5 - - - - - - - - - - - - - - - - - - - - - - - - - economist_fg - - - - 12 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - excel_line - - - - 7 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - excel_fill - - - - 7 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - excel_new - - - - 10 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - few_light - - - - 9 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - few_medium - - - - 9 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - few_dark - - - - 9 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - fivethirtyeight - - - - 6 - - - - - - - - - - - - - - - - - - - - - - - - - - - - gdocs - - - - 20 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - hc_default - - - - 10 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - hc_darkunica - - - - 11 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - solarized_base - - - - 8 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - solarized_accents - - - - 8 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - stata_colors - - - - 73 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - wsj_rgby - - - - 4 - - - - - - - - - - - - - - - - - - - - - - wsj_red_green - - - - 2 - - - - - - - - - - - - - - - - wsj_black_green - - - - 4 - - - - - - - - - - - - - - - - - - - - - - wsj_dem_rep - - - - 3 - - - - - - - - - - - - - - - - - - - wsj_colors6 - - - - 6 - - - - - - - - - - - - - - - - - - - - - - - - - - - - tableau_tableau20 - - - - 20 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - tableau_tableau10medium - - - - 10 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - tableau_gray5 - - - - 5 - - - - - - - - - - - - - - - - - - - - - - - - - tableau_colorblind10 - - - - 10 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - tableau_trafficlight - - - - 9 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - tableau_purplegray12 - - - - 12 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - tableau_bluered12 - - - - 12 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - tableau_greenorange12 - - - - 12 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - tableau_cyclic - - - - 20 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/reference/figures/man_info_time_style_1.svg b/docs/reference/figures/man_info_time_style_1.svg deleted file mode 100644 index abce993e47..0000000000 --- a/docs/reference/figures/man_info_time_style_1.svg +++ /dev/null @@ -1,143 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Preset Time Formats - - - -Usable in the - - - -fmt_time() - - - - and - - - -fmt_datetime() - - - - functions - - - -Time Formats -Formatted Time -Number -Name -1 -hms -14:35:00 -2 -hm -14:35 -3 -hms_p -2:35:00 PM -4 -hm_p -2:35 PM -5 -h_p -2 PM - - - diff --git a/docs/reference/figures/man_local_image_1.svg b/docs/reference/figures/man_local_image_1.svg deleted file mode 100644 index ec3e80c407..0000000000 --- a/docs/reference/figures/man_local_image_1.svg +++ /dev/null @@ -1,128 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -pixels -image -10px - - - - - - - -15px - - - - - - - -20px - - - - - - - -25px - - - - - - - -30px - - - - - - - -35px - - - - - - - diff --git a/docs/reference/figures/man_location_cells_1.svg b/docs/reference/figures/man_location_cells_1.svg deleted file mode 100644 index c7fc5e761f..0000000000 --- a/docs/reference/figures/man_location_cells_1.svg +++ /dev/null @@ -1,132 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -S&P 500 - - - -Open and Close Values - - - -1 - - - -date -open -close -2015-01-09 -2063.45 -2044.81 -2015-01-08 -2030.61 -2062.14 -2015-01-07 -2005.55 -2025.90 -2015-01-06 -2022.15 -2002.61 -2015-01-05 -2054.44 -2020.58 - - - -1 - - - - All values in USD. - - - diff --git a/docs/reference/figures/man_location_cells_2.svg b/docs/reference/figures/man_location_cells_2.svg deleted file mode 100644 index bfb25e03c9..0000000000 --- a/docs/reference/figures/man_location_cells_2.svg +++ /dev/null @@ -1,156 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -tst - - - -1 - - - -sza - - - -2 - - - -0700 -84.9 -0730 -78.7 -0800 -72.7 -0830 -66.1 -0900 -61.5 -0930 -56.5 -1000 -52.1 -1030 -48.3 -1100 -45.5 -1130 -43.6 -1200 -43.0 - - - -1 - - - - True solar time. - - - -2 - - - - Solar zenith angle. - - - diff --git a/docs/reference/figures/man_location_cells_3.svg b/docs/reference/figures/man_location_cells_3.svg deleted file mode 100644 index 9a4f6ea457..0000000000 --- a/docs/reference/figures/man_location_cells_3.svg +++ /dev/null @@ -1,248 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Pizzas Sold -peppr_salami - - - -1 - - - -L -696 -M -428 -S -322 -TOTAL -1,446 -soppressata -L -405 -M -268 -S -288 -TOTAL -961 - - - -1 - - - - The Pepper-Salami. - - - diff --git a/docs/reference/figures/man_location_cells_4.svg b/docs/reference/figures/man_location_cells_4.svg deleted file mode 100644 index 0268007ca8..0000000000 --- a/docs/reference/figures/man_location_cells_4.svg +++ /dev/null @@ -1,675 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -0530 -0600 -0630 -0700 -0730 -0800 -0830 -0900 -0930 -1000 - - - -jan - - - -84.9 -78.7 -72.7 -66.1 -61.5 -56.5 -52.1 - - - -feb - - - -88.9 -82.5 -75.8 -69.6 -63.3 -57.7 -52.2 -47.4 - - - -mar - - - -85.7 -78.8 -72 -65.2 -58.6 -52.3 -46.2 -40.5 - - - -apr - - - -88.5 -81.5 -74.4 -67.4 -60.3 -53.4 -46.5 -39.7 -33.2 - - - -may - - - -85 -78.2 -71.2 -64.3 -57.2 -50.2 -43.2 -36.1 -29.1 - - - -jun - - - -89.2 -82.7 -76 -69.3 -62.5 -55.7 -48.8 -41.9 -35 -28.1 - - - -jul - - - -88.8 -82.3 -75.7 -69.1 -62.3 -55.5 -48.7 -41.8 -35 -28.1 - - - -aug - - - -83.8 -77.1 -70.2 -63.3 -56.4 -49.4 -42.4 -35.4 -28.3 - - - -sep - - - -87.2 -80.2 -73.2 -66.1 -59.1 -52.1 -45.1 -38.1 -31.3 - - - -oct - - - -84.1 -77.1 -70.2 -63.3 -56.5 -49.9 -43.5 -37.5 - - - -nov - - - -87.8 -81.3 -74.5 -68.3 -61.8 -56 -50.2 -45.3 - - - -dec - - - -84.3 -78 -71.8 -66.1 -60.5 -55.6 -50.9 - - - diff --git a/docs/reference/figures/man_location_cells_5.svg b/docs/reference/figures/man_location_cells_5.svg deleted file mode 100644 index d2c49dc420..0000000000 --- a/docs/reference/figures/man_location_cells_5.svg +++ /dev/null @@ -1,185 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -mfr -model -year -hp -Bentley -Continental GT -2016 -500 -Aston Martin -DB11 -2017 -608 -Aston Martin -Rapide S -2016 -552 -Aston Martin -Vanquish -2016 -568 -Aston Martin -Vantage -2016 -430 -Lotus -Evora -2017 -400 -Jaguar -F-Type -2016 -340 -McLaren -570 -2016 -570 -Rolls-Royce -Dawn -2016 -563 -Rolls-Royce -Wraith -2016 -624 - - - -* - - - -* - - - - Highest horsepower. - - - diff --git a/docs/reference/figures/man_location_cells_6.svg b/docs/reference/figures/man_location_cells_6.svg deleted file mode 100644 index 5ec9adb4b7..0000000000 --- a/docs/reference/figures/man_location_cells_6.svg +++ /dev/null @@ -1,294 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -population -1960s -1960 -92,500,572 -1961 -94,943,000 -1962 -95,832,000 -1963 -96,812,000 -1964 -97,826,000 -1965 -98,883,000 -1966 -99,790,000 -1967 -100,725,000 -1968 -101,061,000 -1969 -103,172,000 -min - - - -92,500,572 - - - -max - - - -103,172,000 - - - diff --git a/docs/reference/figures/man_md_1.svg b/docs/reference/figures/man_md_1.svg deleted file mode 100644 index ec6a66f86e..0000000000 --- a/docs/reference/figures/man_md_1.svg +++ /dev/null @@ -1,107 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Using - - - -Markdown - - - -currency -char -49.950 -apricot -17.950 -banana -1.390 -coconut -65100.000 -durian -1325.810 -NA -13.255 -fig -NA -grapefruit -0.440 -honeydew - - - diff --git a/docs/reference/figures/man_row_group_order_1.svg b/docs/reference/figures/man_row_group_order_1.svg deleted file mode 100644 index 02e4e6cba9..0000000000 --- a/docs/reference/figures/man_row_group_order_1.svg +++ /dev/null @@ -1,235 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -char -currency -grp_b -row_5 -NA -1325.810 -row_6 -fig -13.255 -row_7 -grapefruit -NA -row_8 -honeydew -0.440 -grp_a -row_1 -apricot -49.950 -row_2 -banana -17.950 -row_3 -coconut -1.390 -row_4 -durian -65100.000 - - - diff --git a/docs/reference/figures/man_summary_rows_1.svg b/docs/reference/figures/man_summary_rows_1.svg deleted file mode 100644 index c154be650a..0000000000 --- a/docs/reference/figures/man_summary_rows_1.svg +++ /dev/null @@ -1,636 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -open -high -low -close -W02 -2015-01-05 -2054.44 -2054.44 -2017.34 -2020.58 -2015-01-06 -2022.15 -2030.25 -1992.44 -2002.61 -2015-01-07 -2005.55 -2029.61 -2005.55 -2025.90 -2015-01-08 -2030.61 -2064.08 -2030.61 -2062.14 -2015-01-09 -2063.45 -2064.43 -2038.33 -2044.81 -min -2005.55 -2029.61 -1992.44 -2002.61 -max -2063.45 -2064.43 -2038.33 -2062.14 -avg -2035.24 -2048.56 -2016.85 -2031.21 -W03 -2015-01-12 -2046.13 -2049.30 -2022.58 -2028.26 -2015-01-13 -2031.58 -2056.93 -2008.25 -2023.03 -2015-01-14 -2018.40 -2018.40 -1988.44 -2011.27 -2015-01-15 -2013.75 -2021.35 -1991.47 -1992.67 -2015-01-16 -1992.25 -2020.46 -1988.12 -2019.42 -min -1992.25 -2018.40 -1988.12 -1992.67 -max -2046.13 -2056.93 -2022.58 -2028.26 -avg -2020.42 -2033.29 -1999.77 -2014.93 - - - diff --git a/docs/reference/figures/man_tab_footnote_1.svg b/docs/reference/figures/man_tab_footnote_1.svg deleted file mode 100644 index c0595e15cf..0000000000 --- a/docs/reference/figures/man_tab_footnote_1.svg +++ /dev/null @@ -1,216 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -tst -sza - - - -1 - - - -0700 -84.9 -0730 -78.7 -0800 -72.7 -0830 -66.1 -0900 -61.5 -0930 -56.5 -1000 -52.1 -1030 -48.3 -1100 -45.5 -1130 -43.6 -1200 -43.0 - - - -1 - - - - Color indicates height of sun. - - - diff --git a/docs/reference/figures/man_tab_header_1.svg b/docs/reference/figures/man_tab_header_1.svg deleted file mode 100644 index 00e4c6c163..0000000000 --- a/docs/reference/figures/man_tab_header_1.svg +++ /dev/null @@ -1,124 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Data listing from - - - -gtcars - - - -gtcars - - - - is an R dataset - - - -mfr -model -msrp -Ford -GT -447000 -Ferrari -458 Speciale -291744 -Ferrari -458 Spider -263553 -Ferrari -458 Italia -233509 -Ferrari -488 GTB -245400 - - - diff --git a/docs/reference/figures/man_tab_options_1.svg b/docs/reference/figures/man_tab_options_1.svg deleted file mode 100644 index bfdfde648c..0000000000 --- a/docs/reference/figures/man_tab_options_1.svg +++ /dev/null @@ -1,397 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Data listing from - - - -exibble - - - -exibble - - - - is an R dataset - - - -num -char - - - -1 - - - -currency -grp_a -row_1 -0.11 -apricot -$49.95 -row_2 -2.22 -banana -$17.95 -row_3 -33.33 -coconut -$1.39 -row_4 -444.40 -durian -$65,100.00 - - - -2 - - - -grp_b -row_5 -5,550.00 - - - -2 - - - -NA -$1,325.81 - - - -2 - - - -row_6 -NA -fig -$13.26 -row_7 -777,000.00 - - - -2 - - - -grapefruit -NA -row_8 -8,880,000.00 - - - -2 - - - -honeydew -$0.44 - - - -1 - - - - Alphabetical fruit. - - - -2 - - - - Using commas for separators. - - - diff --git a/docs/reference/figures/man_tab_options_2.svg b/docs/reference/figures/man_tab_options_2.svg deleted file mode 100644 index 7cfa9c839b..0000000000 --- a/docs/reference/figures/man_tab_options_2.svg +++ /dev/null @@ -1,397 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Data listing from - - - -exibble - - - -exibble - - - - is an R dataset - - - -num -char - - - -1 - - - -currency -grp_a -row_1 -0.11 -apricot -$49.95 -row_2 -2.22 -banana -$17.95 -row_3 -33.33 -coconut -$1.39 -row_4 -444.40 -durian -$65,100.00 - - - -2 - - - -grp_b -row_5 -5,550.00 - - - -2 - - - -NA -$1,325.81 - - - -2 - - - -row_6 -NA -fig -$13.26 -row_7 -777,000.00 - - - -2 - - - -grapefruit -NA -row_8 -8,880,000.00 - - - -2 - - - -honeydew -$0.44 - - - -1 - - - - Alphabetical fruit. - - - -2 - - - - Using commas for separators. - - - diff --git a/docs/reference/figures/man_tab_options_3.svg b/docs/reference/figures/man_tab_options_3.svg deleted file mode 100644 index 5d21df63d7..0000000000 --- a/docs/reference/figures/man_tab_options_3.svg +++ /dev/null @@ -1,402 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Data listing from - - - -exibble - - - -exibble - - - - is an R dataset - - - -num -char - - - -1 - - - -currency -grp_a -row_1 -0.11 -apricot -$49.95 -row_2 -2.22 -banana -$17.95 -row_3 -33.33 -coconut -$1.39 -row_4 -444.40 -durian -$65,100.00 - - - -2 - - - -grp_b -row_5 -5,550.00 - - - -2 - - - -NA -$1,325.81 - - - -2 - - - -row_6 -NA -fig -$13.26 -row_7 -777,000.00 - - - -2 - - - -grapefruit -NA -row_8 -8,880,000.00 - - - -2 - - - -honeydew -$0.44 - - - -1 - - - - Alphabetical fruit. - - - -2 - - - - Using commas for separators. - - - diff --git a/docs/reference/figures/man_tab_options_4.svg b/docs/reference/figures/man_tab_options_4.svg deleted file mode 100644 index c20c0a2c59..0000000000 --- a/docs/reference/figures/man_tab_options_4.svg +++ /dev/null @@ -1,397 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Data listing from - - - -exibble - - - -exibble - - - - is an R dataset - - - -num -char - - - -a - - - -currency -grp_a -row_1 -0.11 -apricot -$49.95 -row_2 -2.22 -banana -$17.95 -row_3 -33.33 -coconut -$1.39 -row_4 -444.40 -durian -$65,100.00 - - - -b - - - -grp_b -row_5 -5,550.00 - - - -b - - - -NA -$1,325.81 - - - -b - - - -row_6 -NA -fig -$13.26 -row_7 -777,000.00 - - - -b - - - -grapefruit -NA -row_8 -8,880,000.00 - - - -b - - - -honeydew -$0.44 - - - -a - - - - Alphabetical fruit. - - - -b - - - - Using commas for separators. - - - diff --git a/docs/reference/figures/man_tab_options_5.svg b/docs/reference/figures/man_tab_options_5.svg deleted file mode 100644 index 8ad023529a..0000000000 --- a/docs/reference/figures/man_tab_options_5.svg +++ /dev/null @@ -1,397 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Data listing from - - - -exibble - - - -exibble - - - - is an R dataset - - - -num -char - - - -1 - - - -currency -grp_a -row_1 -0.11 -apricot -$49.95 -row_2 -2.22 -banana -$17.95 -row_3 -33.33 -coconut -$1.39 -row_4 -444.40 -durian -$65,100.00 - - - -2 - - - -grp_b -row_5 -5,550.00 - - - -2 - - - -NA -$1,325.81 - - - -2 - - - -row_6 -NA -fig -$13.26 -row_7 -777,000.00 - - - -2 - - - -grapefruit -NA -row_8 -8,880,000.00 - - - -2 - - - -honeydew -$0.44 - - - -1 - - - - Alphabetical fruit. - - - -2 - - - - Using commas for separators. - - - diff --git a/docs/reference/figures/man_tab_options_6.svg b/docs/reference/figures/man_tab_options_6.svg deleted file mode 100644 index bcb488306b..0000000000 --- a/docs/reference/figures/man_tab_options_6.svg +++ /dev/null @@ -1,397 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Data listing from - - - -exibble - - - -exibble - - - - is an R dataset - - - -num -char - - - -1 - - - -currency -grp_a -row_1 -0.11 -apricot -$49.95 -row_2 -2.22 -banana -$17.95 -row_3 -33.33 -coconut -$1.39 -row_4 -444.40 -durian -$65,100.00 - - - -2 - - - -grp_b -row_5 -5,550.00 - - - -2 - - - -NA -$1,325.81 - - - -2 - - - -row_6 -NA -fig -$13.26 -row_7 -777,000.00 - - - -2 - - - -grapefruit -NA -row_8 -8,880,000.00 - - - -2 - - - -honeydew -$0.44 - - - -1 - - - - Alphabetical fruit. - - - -2 - - - - Using commas for separators. - - - diff --git a/docs/reference/figures/man_tab_row_group_1.svg b/docs/reference/figures/man_tab_row_group_1.svg deleted file mode 100644 index f2072ab2ee..0000000000 --- a/docs/reference/figures/man_tab_row_group_1.svg +++ /dev/null @@ -1,262 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -year -hp -trq -numbered -458 Speciale -2015 -597 -398 -458 Spider -2015 -562 -398 -458 Italia -2014 -562 -398 -488 GTB -2016 -661 -561 -GT -2017 -647 -550 -California -2015 -553 -557 -GTC4Lusso -2017 -680 -514 -FF -2015 -652 -504 - - - diff --git a/docs/reference/figures/man_tab_row_group_2.svg b/docs/reference/figures/man_tab_row_group_2.svg deleted file mode 100644 index bee92ff695..0000000000 --- a/docs/reference/figures/man_tab_row_group_2.svg +++ /dev/null @@ -1,264 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -year -hp -trq -powerful -458 Speciale -2015 -597 -398 -458 Spider -2015 -562 -398 -458 Italia -2014 -562 -398 -California -2015 -553 -557 -super powerful -GT -2017 -647 -550 -488 GTB -2016 -661 -561 -GTC4Lusso -2017 -680 -514 -FF -2015 -652 -504 - - - diff --git a/docs/reference/figures/man_tab_source_note_1.svg b/docs/reference/figures/man_tab_source_note_1.svg deleted file mode 100644 index e15e40b99f..0000000000 --- a/docs/reference/figures/man_tab_source_note_1.svg +++ /dev/null @@ -1,100 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -mfr -model -msrp -Ford -GT -447000 -Ferrari -458 Speciale -291744 -Ferrari -458 Spider -263553 -Ferrari -458 Italia -233509 -Ferrari -488 GTB -245400 - - - -From edmunds.com - - - diff --git a/docs/reference/figures/man_tab_spanner_1.svg b/docs/reference/figures/man_tab_spanner_1.svg deleted file mode 100644 index b3f29d7081..0000000000 --- a/docs/reference/figures/man_tab_spanner_1.svg +++ /dev/null @@ -1,402 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -year -bdy_style -performance -msrp -hp -hp_rpm -trq -trq_rpm -mpg_c -mpg_h -GT -2017 -coupe -647 -6250 -550 -5900 -11 -18 -447000 -458 Speciale -2015 -coupe -597 -9000 -398 -6000 -13 -17 -291744 -458 Spider -2015 -convertible -562 -9000 -398 -6000 -13 -17 -263553 -458 Italia -2014 -coupe -562 -9000 -398 -6000 -13 -17 -233509 -488 GTB -2016 -coupe -661 -8000 -561 -3000 -15 -22 -245400 -California -2015 -convertible -553 -7500 -557 -4750 -16 -23 -198973 -GTC4Lusso -2017 -coupe -680 -8250 -514 -5750 -12 -17 -298000 -FF -2015 -coupe -652 -8000 -504 -6000 -11 -16 -295000 - - - diff --git a/docs/reference/figures/man_tab_stubhead_label_1.svg b/docs/reference/figures/man_tab_stubhead_label_1.svg deleted file mode 100644 index 040611805e..0000000000 --- a/docs/reference/figures/man_tab_stubhead_label_1.svg +++ /dev/null @@ -1,161 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -car -year -hp -trq -GT -2017 -647 -550 -458 Speciale -2015 -597 -398 -458 Spider -2015 -562 -398 -458 Italia -2014 -562 -398 -488 GTB -2016 -661 -561 - - - diff --git a/docs/reference/figures/man_tab_style_1.svg b/docs/reference/figures/man_tab_style_1.svg deleted file mode 100644 index 5e7f5ba958..0000000000 --- a/docs/reference/figures/man_tab_style_1.svg +++ /dev/null @@ -1,217 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -num -currency -0.1 - - - -50.0 - - - -2.2 - - - -17.9 - - - -33.3 - - - -1.4 - - - -444.4 -65,100.0 - - - -5,550.0 - - - -1,325.8 -NA - - - -13.3 - - - -777,000.0 - - - -NA - - - -8,880,000.0 - - - -0.4 - - - diff --git a/docs/reference/figures/man_tab_style_2.svg b/docs/reference/figures/man_tab_style_2.svg deleted file mode 100644 index 70cd221c6e..0000000000 --- a/docs/reference/figures/man_tab_style_2.svg +++ /dev/null @@ -1,560 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -date -open -high -low -close -2015-12-15 -2025.55 -2053.87 -2025.55 -2043.41 -2015-12-14 -2013.37 -2022.92 -1993.26 -2021.94 - - - -2015-12-11 -2047.27 -2047.27 -2008.80 -2012.37 - - - -2015-12-10 -2047.93 -2067.65 -2045.67 -2052.23 - - - -2015-12-09 -2061.17 -2080.33 -2036.53 -2047.62 -2015-12-08 -2073.39 -2073.85 -2052.32 -2063.59 -2015-12-07 -2090.42 -2090.42 -2066.78 -2077.07 - - - -2015-12-04 -2051.24 -2093.84 -2051.24 -2091.69 - - - -2015-12-03 -2080.71 -2085.00 -2042.35 -2049.62 -2015-12-02 -2101.71 -2104.27 -2077.11 -2079.51 - - - -2015-12-01 -2082.93 -2103.37 -2082.93 -2102.63 - - - diff --git a/docs/reference/figures/man_text_transform_1.svg b/docs/reference/figures/man_text_transform_1.svg deleted file mode 100644 index e30b28e4c1..0000000000 --- a/docs/reference/figures/man_text_transform_1.svg +++ /dev/null @@ -1,86 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -num -char -currency -0.11 (small) -apricot -$49.95 -2.22 (small) -banana -$17.95 -33.33 (large) -coconut -$1.39 -444.40 (large) -durian -$65,100 - - - diff --git a/docs/reference/figures/man_web_image_1.svg b/docs/reference/figures/man_web_image_1.svg deleted file mode 100644 index 9db09ad455..0000000000 --- a/docs/reference/figures/man_web_image_1.svg +++ /dev/null @@ -1,128 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -pixels -image -10px - - - - - - - -15px - - - - - - - -20px - - - - - - - -25px - - - - - - - -30px - - - - - - - -35px - - - - - - - diff --git a/docs/reference/figures/man_web_image_2.svg b/docs/reference/figures/man_web_image_2.svg deleted file mode 100644 index bc7cdb64d1..0000000000 --- a/docs/reference/figures/man_web_image_2.svg +++ /dev/null @@ -1,231 +0,0 @@ - - -Qt Svg Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -pixels -image -10px -10 -15px -15 -20px -20 -25px -25 -30px -30 -35px -35 - - - diff --git a/docs/reference/figures/rstudio-cloud-example.png b/docs/reference/figures/rstudio-cloud-example.png deleted file mode 100644 index d43ad4aa77..0000000000 Binary files a/docs/reference/figures/rstudio-cloud-example.png and /dev/null differ diff --git a/docs/reference/figures/rstudio-cloud-example.svg b/docs/reference/figures/rstudio-cloud-example.svg deleted file mode 100644 index 0687b62ecf..0000000000 --- a/docs/reference/figures/rstudio-cloud-example.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - rstudio-cloud-example - Created with Sketch. - - - - - - - - - - - \ No newline at end of file diff --git a/docs/reference/fmt.html b/docs/reference/fmt.html deleted file mode 100644 index 182854e925..0000000000 --- a/docs/reference/fmt.html +++ /dev/null @@ -1,276 +0,0 @@ - - - - - - - - -Set a column format with a formatter function ā€” fmt ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    The fmt() function provides greater control in formatting raw data -values than any of the specialized fmt_*() functions that are -available in gt. Along with the columns and rows -arguments that provide some precision in targeting data cells, the fns -argument allows you to define one or more functions for manipulating the raw -data.

    - -
    - -
    fmt(data, columns = NULL, rows = NULL, fns)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    columns

    the columns to format. Can either be a series of column names -provided in vars(), a vector of column indices, or a helper function -focused on selections. The select helper functions are: -starts_with(), ends_with(), -contains(), matches(), one_of(), -and everything().

    rows

    optional rows to format. Not providing any value results in all -rows in columns being formatted. Can either be a vector of row -captions provided c(), a vector of row indices, or a helper function -focused on selections. The select helper functions are: -starts_with(), ends_with(), -contains(), matches(), one_of(), -and everything(). We can also use expressions to filter down -to the rows we need (e.g., [colname_1] > 100 & [colname_2] < 50).

    fns

    a single formatting function or a named list of functions.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Details

    - -

    If providing a single function to fns, the recommended format is in -the form: fns = function(x) .... This single function will format the -targeted data cells the same way regardless of the output format (e.g., HTML, -LaTeX, RTF).

    -

    If you require formatting of x that depends on the output format, a -list of functions can be provided for the html, latex, and -default contexts. This can be in the form of fns = list(html = -function(x) ..., latex = function(x) ..., default = function(x) ...). In -this multiple-function case, we recommended including the default -function as a fallback if all contexts aren't provided.

    -

    As with all of the fmt_*() functions, targeting of values is done -through columns and additionally by rows (if nothing is -provided for rows then entire columns are selected). A number of -helper functions exist to make targeting more effective. Conditional -formatting is possible by providing a conditional expression to the -rows argument. See the Arguments section for more information on this.

    - -

    Figures

    - - -

    - -

    See also

    - - - - -

    Examples

    -
    # Use `exibble` to create a gt table; -# format the numeric values in the `num` -# column with a function supplied to -# the `fns` argument -tab_1 <- - exibble %>% - dplyr::select(-row, -group) %>% - gt() %>% - fmt( - columns = vars(num), - fns = function(x) { - paste0("'", x * 1000, "'") - } - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/fmt_currency.html b/docs/reference/fmt_currency.html deleted file mode 100644 index 21993bada9..0000000000 --- a/docs/reference/fmt_currency.html +++ /dev/null @@ -1,389 +0,0 @@ - - - - - - - - -Format values as currencies ā€” fmt_currency ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    With numeric values in a gt table, we can perform currency-based -formatting. This function supports both automatic formatting with a -three-letter currency code and numeric formatting facilitated through the use -of a locale ID. For fine control the conversion from numeric to currency -values, we can take advantage of the following options:

      -
    • the currency: providing a currency code or common currency name will -procure the correct currency symbol and number of currency subunits

    • -
    • currency symbol placement: the currency symbol can be placed before -or after the values

    • -
    • decimals/subunits: choice of the number of decimal places, and a -choice of the decimal symbol, and an option on whether to include or exclude -the currency subunits (decimal portion)

    • -
    • negative values: choice of a negative sign or parentheses for values -less than zero

    • -
    • digit grouping separators: options to enable/disable digit separators -and provide a choice of separator symbol

    • -
    • scaling: we can choose to scale targeted values by a multiplier value

    • -
    • pattern: option to use a text pattern for decoration of the formatted -currency values

    • -
    • locale-based formatting: providing a locale ID will result in -currency formatting specific to the chosen locale

    • -
    - -
    - -
    fmt_currency(data, columns, rows = NULL, currency = "USD",
    -  use_subunits = TRUE, negative_val = "signed", decimals = NULL,
    -  use_seps = TRUE, scale_by = 1, pattern = "{x}", sep_mark = ",",
    -  dec_mark = ".", placement = "left", incl_space = FALSE,
    -  locale = NULL)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    columns

    the columns to format. Can either be a series of column names -provided in vars(), a vector of column indices, or a helper function -focused on selections. The select helper functions are: -starts_with(), ends_with(), -contains(), matches(), one_of(), -and everything().

    rows

    optional rows to format. Not providing any value results in all -rows in columns being formatted. Can either be a vector of row -captions provided c(), a vector of row indices, or a helper function -focused on selections. The select helper functions are: -starts_with(), ends_with(), -contains(), matches(), one_of(), -and everything(). We can also use expressions to filter down -to the rows we need (e.g., [colname_1] > 100 & [colname_2] < 50).

    currency

    the currency to use for the numeric value. This input can be -supplied as a 3-letter currency code (e.g., "USD" for U.S. Dollars, -"EUR" for the Euro currency). Use info_currencies() to -get an information table with all of the valid currency codes and examples -of each. Alternatively, we can provide a common currency name (e.g., -"dollar", "pound", "yen", etc.) to simplify the -process. Use info_currencies() with the type == -"symbol" option to view an information table with all of the supported -currency symbol names along with examples. If nothing is provided then -"USD" will be used.

    use_subunits

    an option for whether the subunits portion of a currency -value should be displayed.

    negative_val

    the formatting to use for negative values. With -signed (the default), negative values will be shown with a negative -sign. Using parens will show the negative value in parentheses.

    decimals

    an option to specify the exact number of decimal places to -use. The default number of decimal places is 2.

    use_seps

    an option to use digit group separators. The type of digit -group separator is set by sep_mark and overridden if a locale ID is -provided to locale. This setting is TRUE by default.

    scale_by

    a value to scale the input. The default is 1.0.

    pattern

    a formatting pattern that allows for decoration of the -formatted value. The value itself is represented by {x} and all -other characters are taken to be string literals.

    sep_mark

    the mark to use as a separator between groups of digits -(e.g., using sep_mark = "," with 1000 would result in a -formatted value of 1,000).

    dec_mark

    the character to use as a decimal mark (e.g., using -dec_mark = "," with 0.152 would result in a formatted value -of 0,152).

    placement

    the placement of the currency symbol. This can be either be -left (the default) or right.

    incl_space

    an option on whether to include a space between the value -and the currency symbol. The default is to not introduce a space character.

    locale

    an optional locale ID that can be used for formatting the value -according the locale's rules. Examples include "en_US" for English -(United States) and "fr_FR" for French (France). The use of a valid -locale ID will override any values provided in sep_mark and -dec_mark.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Details

    - -

    We can use the info_currencies() function for a useful -reference on all of the possible inputs to currency.

    -

    Targeting of values is done through columns and additionally by -rows (if nothing is provided for rows then entire columns are -selected). A number of helper functions exist to make targeting more -effective. Conditional formatting is possible by providing a conditional -expression to the rows argument. See the Arguments section for more -information on this.

    - -

    Figures

    - - -

    -

    - -

    See also

    - - - - -

    Examples

    -
    # Use `exibble` to create a gt table; -# format the `currency` column to have -# currency values in euros (EUR) -tab_1 <- - exibble %>% - gt() %>% - fmt_currency( - columns = vars(currency), - currency = "EUR" - ) - -# Use `exibble` to create a gt table; -# Keep only the `num` and `currency`, -# columns, then, format those columns -# using the "CNY" and "GBP" currencies -tab_2 <- - exibble %>% - dplyr::select(num, currency) %>% - gt() %>% - fmt_currency( - columns = vars(num), - currency = "CNY" - ) %>% - fmt_currency( - columns = vars(currency), - currency = "GBP" - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/fmt_date.html b/docs/reference/fmt_date.html deleted file mode 100644 index 5d91d5c353..0000000000 --- a/docs/reference/fmt_date.html +++ /dev/null @@ -1,309 +0,0 @@ - - - - - - - - -Format values as dates ā€” fmt_date ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Format input date values that are character-based and expressed according to -the ISO 8601 date format (YYYY-MM-DD). Once the appropriate data cells -are targeted with columns (and, optionally, rows), we can -simply apply a preset date style (see table in -info_date_style() for info) to format the dates.

    - -
    - -
    fmt_date(data, columns, rows = NULL, date_style = 2)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    columns

    the columns to format. Can either be a series of column names -provided in vars(), a vector of column indices, or a helper function -focused on selections. The select helper functions are: -starts_with(), ends_with(), -contains(), matches(), one_of(), -and everything().

    rows

    optional rows to format. Not providing any value results in all -rows in columns being formatted. Can either be a vector of row -captions provided c(), a vector of row indices, or a helper function -focused on selections. The select helper functions are: -starts_with(), ends_with(), -contains(), matches(), one_of(), -and everything(). We can also use expressions to filter down -to the rows we need (e.g., [colname_1] > 100 & [colname_2] < 50).

    date_style

    the date style to use. Supply a number (from 1 to -14) that corresponds to the preferred date style. Use -info_date_style() to see the different numbered and named date -presets.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Details

    - -

    The following date styles are available for simpler formatting of ISO dates -(all using the input date of 2000-02-29 in the example output dates):

    -
      -
    1. iso: 2000-02-29

    2. -
    3. wday_month_day_year: Tuesday, February 29, 2000

    4. -
    5. wd_m_day_year: Tue, Feb 29, 2000

    6. -
    7. wday_day_month_year: Tuesday 29 February 2000

    8. -
    9. month_day_year: February 29, 2000

    10. -
    11. m_day_year: Feb 29, 2000

    12. -
    13. day_m_year: 29 Feb 2000

    14. -
    15. day_month_year: 29 February 2000

    16. -
    17. day_month: 29 February

    18. -
    19. year: 2000

    20. -
    21. month: February

    22. -
    23. day: 29

    24. -
    25. year.mn.day: 2000/02/29

    26. -
    27. y.mn.day: 0/02/29

    28. -
    -

    We can use the info_date_style() function for a useful -reference on all of the possible inputs to date_style.

    -

    Targeting of values is done through columns and additionally by -rows (if nothing is provided for rows then entire columns are -selected). A number of helper functions exist to make targeting more -effective. Conditional formatting is possible by providing a conditional -expression to the rows argument. See the Arguments section for more -information on this.

    - -

    Figures

    - - -

    -

    - -

    See also

    - - - - -

    Examples

    -
    # Use `exibble` to create a gt table; -# keep only the `date` and `time` columns; -# format the `date` column to have -# dates formatted as `month_day_year` -# (date style `5`) -tab_1 <- - exibble %>% - dplyr::select(date, time) %>% - gt() %>% - fmt_date( - columns = vars(date), - date_style = 5 - ) - -# Use `exibble` to create a gt table; -# keep only the `date` and `time` columns; -# format the `date` column to have mixed -# date formats (dates after April will -# be different than the others) -tab_2 <- - exibble %>% - dplyr::select(date, time) %>% - gt() %>% - fmt_date( - columns = vars(date), - rows = - as.Date(date) > as.Date("2015-04-01"), - date_style = 6 - ) %>% - fmt_date( - columns = vars(date), - rows = - as.Date(date) <= as.Date("2015-04-01"), - date_style = 7 - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/fmt_datetime.html b/docs/reference/fmt_datetime.html deleted file mode 100644 index 9d830d89fd..0000000000 --- a/docs/reference/fmt_datetime.html +++ /dev/null @@ -1,309 +0,0 @@ - - - - - - - - -Format values as date-times ā€” fmt_datetime ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Format input date-time values that are character-based and expressed -according to the ISO 8601 date-time format (YYYY-MM-DD HH:MM:SS). Once -the appropriate data cells are targeted with columns (and, optionally, -rows), we can simply apply preset date and time styles (see tables in -info_date_style() and info_time_style() for more -info) to format the data-time values.

    - -
    - -
    fmt_datetime(data, columns, rows = NULL, date_style = 2,
    -  time_style = 2)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    columns

    the columns to format. Can either be a series of column names -provided in vars(), a vector of column indices, or a helper function -focused on selections. The select helper functions are: -starts_with(), ends_with(), -contains(), matches(), one_of(), -and everything().

    rows

    optional rows to format. Not providing any value results in all -rows in columns being formatted. Can either be a vector of row -captions provided c(), a vector of row indices, or a helper function -focused on selections. The select helper functions are: -starts_with(), ends_with(), -contains(), matches(), one_of(), -and everything(). We can also use expressions to filter down -to the rows we need (e.g., [colname_1] > 100 & [colname_2] < 50).

    date_style

    the date style to use. Supply a number (from 1 to -14) that corresponds to the preferred date style. Use -info_date_style() to see the different numbered and named date -presets.

    time_style

    the time style to use. Supply a number (from 1 to -5) that corresponds to the preferred time style. Use -info_time_style() to see the different numbered and named time -presets.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Details

    - -

    The following date styles are available for simpler formatting of the date -portion (all using the input date of 2000-02-29 in the example output -dates):

    -
      -
    1. iso: 2000-02-29

    2. -
    3. wday_month_day_year: Tuesday, February 29, 2000

    4. -
    5. wd_m_day_year: Tue, Feb 29, 2000

    6. -
    7. wday_day_month_year: Tuesday 29 February 2000

    8. -
    9. month_day_year: February 29, 2000

    10. -
    11. m_day_year: Feb 29, 2000

    12. -
    13. day_m_year: 29 Feb 2000

    14. -
    15. day_month_year: 29 February 2000

    16. -
    17. day_month: 29 February

    18. -
    19. year: 2000

    20. -
    21. month: February

    22. -
    23. day: 29

    24. -
    25. year.mn.day: 2000/02/29

    26. -
    27. y.mn.day: 0/02/29

    28. -
    -

    The following time styles are available for simpler formatting of the time -portion (all using the input time of 14:35:00 in the example output -times):

    -
      -
    1. hms: 14:35:00

    2. -
    3. hm: 14:35

    4. -
    5. hms_p: 2:35:00 PM

    6. -
    7. hm_p: 2:35 PM

    8. -
    9. h_p: 2 PM

    10. -
    -

    We can use the info_date_style() and -info_time_style() functions as useful references for all of the -possible inputs to date_style and time_style.

    -

    Targeting of values is done through columns and additionally by -rows (if nothing is provided for rows then entire columns are -selected). A number of helper functions exist to make targeting more -effective. Conditional formatting is possible by providing a conditional -expression to the rows argument. See the Arguments section for more -information on this.

    - -

    Figures

    - - -

    - -

    See also

    - - - - -

    Examples

    -
    # Use `exibble` to create a gt table; -# keep only the `datetime` column; -# format the column to have dates -# formatted as `month_day_year` and -# times to be `hms_p` -tab_1 <- - exibble %>% - dplyr::select(datetime) %>% - gt() %>% - fmt_datetime( - columns = vars(datetime), - date_style = 5, - time_style = 3 - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/fmt_missing.html b/docs/reference/fmt_missing.html deleted file mode 100644 index aa71a8b388..0000000000 --- a/docs/reference/fmt_missing.html +++ /dev/null @@ -1,264 +0,0 @@ - - - - - - - - -Format missing values ā€” fmt_missing ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Wherever there is missing data (i.e., NA values) a customizable mark -may present better than the standard NA text that would otherwise -appear. The fmt_missing() function allows for this replacement through -its missing_text argument (where an em dash serves as the default).

    - -
    - -
    fmt_missing(data, columns, rows = NULL, missing_text = "---")
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    columns

    the columns to format. Can either be a series of column names -provided in vars(), a vector of column indices, or a helper function -focused on selections. The select helper functions are: -starts_with(), ends_with(), -contains(), matches(), one_of(), -and everything().

    rows

    optional rows to format. Not providing any value results in all -rows in columns being formatted. Can either be a vector of row -captions provided c(), a vector of row indices, or a helper function -focused on selections. The select helper functions are: -starts_with(), ends_with(), -contains(), matches(), one_of(), -and everything(). We can also use expressions to filter down -to the rows we need (e.g., [colname_1] > 100 & [colname_2] < 50).

    missing_text

    the text to be used in place of NA values in the -rendered table.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Details

    - -

    Targeting of values is done through columns and additionally by -rows (if nothing is provided for rows then entire columns are -selected). A number of helper functions exist to make targeting more -effective. Conditional formatting is possible by providing a conditional -expression to the rows argument. See the Arguments section for more -information on this.

    - -

    Figures

    - - -

    - -

    See also

    - - - - -

    Examples

    -
    # Use `exibble` to create a gt table; -# NA values in different columns will -# be given replacement text -tab_1 <- - exibble %>% - dplyr::select(-row, -group) %>% - gt() %>% - fmt_missing( - columns = 1:2, - missing_text = "missing" - ) %>% - fmt_missing( - columns = 4:7, - missing_text = "nothing" - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/fmt_number.html b/docs/reference/fmt_number.html deleted file mode 100644 index bc8983463c..0000000000 --- a/docs/reference/fmt_number.html +++ /dev/null @@ -1,354 +0,0 @@ - - - - - - - - -Format numeric values ā€” fmt_number ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    With numeric values in a gt table, we can perform number-based -formatting so that the targeted values are rendered with a higher -consideration for tabular presentation. Furthermore, there is finer control -over numeric foramtting with the following options:

      -
    • decimals: choice of the number of decimal places, option to drop -trailing zeros, and a choice of the decimal symbol

    • -
    • negative values: choice of a negative sign or parentheses for values -less than zero

    • -
    • digit grouping separators: options to enable/disable digit separators -and provide a choice of separator symbol

    • -
    • scaling: we can choose to scale targeted values by a multiplier value

    • -
    • pattern: option to use a text pattern for decoration of the formatted -values

    • -
    • locale-based formatting: providing a locale ID will result in number -formatting specific to the chosen locale

    • -
    - -
    - -
    fmt_number(data, columns, rows = NULL, decimals = 2,
    -  drop_trailing_zeros = FALSE, negative_val = "signed",
    -  use_seps = TRUE, scale_by = 1, pattern = "{x}", sep_mark = ",",
    -  dec_mark = ".", locale = NULL)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    columns

    the columns to format. Can either be a series of column names -provided in vars(), a vector of column indices, or a helper function -focused on selections. The select helper functions are: -starts_with(), ends_with(), -contains(), matches(), one_of(), -and everything().

    rows

    optional rows to format. Not providing any value results in all -rows in columns being formatted. Can either be a vector of row -captions provided c(), a vector of row indices, or a helper function -focused on selections. The select helper functions are: -starts_with(), ends_with(), -contains(), matches(), one_of(), -and everything(). We can also use expressions to filter down -to the rows we need (e.g., [colname_1] > 100 & [colname_2] < 50).

    decimals

    an option to specify the exact number of decimal places to -use. The default number of decimal places is 2.

    drop_trailing_zeros

    a logical value that allows for removal of -trailing zeros (those redundant zeros after the decimal mark).

    negative_val

    the formatting to use for negative values. With -signed (the default), negative values will be shown with a negative -sign. Using parens will show the negative value in parentheses.

    use_seps

    an option to use digit group separators. The type of digit -group separator is set by sep_mark and overridden if a locale ID is -provided to locale. This setting is TRUE by default.

    scale_by

    a value to scale the input. The default is 1.0.

    pattern

    a formatting pattern that allows for decoration of the -formatted value. The value itself is represented by {x} and all -other characters are taken to be string literals.

    sep_mark

    the mark to use as a separator between groups of digits -(e.g., using sep_mark = "," with 1000 would result in a -formatted value of 1,000).

    dec_mark

    the character to use as a decimal mark (e.g., using -dec_mark = "," with 0.152 would result in a formatted value -of 0,152).

    locale

    an optional locale ID that can be used for formatting the value -according the locale's rules. Examples include "en_US" for English -(United States) and "fr_FR" for French (France). The use of a valid -locale ID will override any values provided in sep_mark and -dec_mark.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Details

    - -

    Targeting of values is done through columns and additionally by -rows (if nothing is provided for rows then entire columns are -selected). A number of helper functions exist to make targeting more -effective. Conditional formatting is possible by providing a conditional -expression to the rows argument. See the Arguments section for more -information on this.

    - -

    Figures

    - - -

    -

    - -

    See also

    - - - - -

    Examples

    -
    # 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 `exibble` to create a gt table; -# format the `num` column as numeric, -# but treating the first four rows -# different than the last four -tab_2 <- - exibble %>% - gt() %>% - fmt_number( - columns = vars(num), - rows = 1:4, - decimals = 2) %>% - fmt_number( - columns = vars(num), - rows = 5:8, - decimals = 1, - scale_by = 1/1000, - pattern = "{x}K")
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/fmt_passthrough.html b/docs/reference/fmt_passthrough.html deleted file mode 100644 index 3ab6686468..0000000000 --- a/docs/reference/fmt_passthrough.html +++ /dev/null @@ -1,282 +0,0 @@ - - - - - - - - -Format by simply passing data through ā€” fmt_passthrough ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Format by passing data through no other transformation other than: (1) -coercing to character (as all the fmt_*() functions do), and -(2) applying prefixed or suffixed text via the pattern argument (the -default is to apply nothing). All of this is useful when don't want to modify -the input data other than to decorate it within a pattern. Also, this -function is useful when used as a formatter function in the -summary_rows function, where the output may be text or useful as is -(that function requires a formatter function).

    - -
    - -
    fmt_passthrough(data, columns, rows = NULL, escape = TRUE,
    -  pattern = "{x}")
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    columns

    the columns to format. Can either be a series of column names -provided in vars(), a vector of column indices, or a helper function -focused on selections. The select helper functions are: -starts_with(), ends_with(), -contains(), matches(), one_of(), -and everything().

    rows

    optional rows to format. Not providing any value results in all -rows in columns being formatted. Can either be a vector of row -captions provided c(), a vector of row indices, or a helper function -focused on selections. The select helper functions are: -starts_with(), ends_with(), -contains(), matches(), one_of(), -and everything(). We can also use expressions to filter down -to the rows we need (e.g., [colname_1] > 100 & [colname_2] < 50).

    escape

    an option to escape text according to the final output format -of the table. For example, if a LaTeX table is to be generated then LaTeX -escaping would be performed during rendering. By default this is set to -TRUE and setting to FALSE is useful in the case where -LaTeX-formatted text should be passed through to the output LaTeX table -unchanged.

    pattern

    a formatting pattern that allows for decoration of the -formatted value. The value itself is represented by {x} and all -other characters are taken to be string literals.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Details

    - -

    Targeting of values is done through columns and additionally by -rows (if nothing is provided for rows then entire columns are -selected). A number of helper functions exist to make targeting more -effective. Conditional formatting is possible by providing a conditional -expression to the rows argument. See the Arguments section for more -information on this.

    - -

    Figures

    - - -

    - -

    See also

    - - - - -

    Examples

    -
    # Use `exibble` to create a gt table; -# keep only the `char` column; -# pass the data in that column through -# but apply a simple pattern that adds -# an 's' to the non-NA values -tab_1 <- - exibble %>% - dplyr::select(char) %>% - gt() %>% - fmt_passthrough( - columns = vars(char), - rows = !is.na(char), - pattern = "{x}s" - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/fmt_percent.html b/docs/reference/fmt_percent.html deleted file mode 100644 index a2694eccd7..0000000000 --- a/docs/reference/fmt_percent.html +++ /dev/null @@ -1,348 +0,0 @@ - - - - - - - - -Format values as a percentage ā€” fmt_percent ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    With numeric values in a gt table, we can perform percentage-based -formatting. It is assumed the input numeric values are in a fractional format -since the will be automatically multplied by 100 before decorating -with a percent sign. For more control over percentage formatting, we can use -the following options:

      -
    • percent sign placement: the percent sign can be placed after or -before the values and a space can be inserted between the symbol and the -value.

    • -
    • decimals: choice of the number of decimal places, option to drop -trailing zeros, and a choice of the decimal symbol

    • -
    • negative values: choice of a negative sign or parentheses for values -less than zero

    • -
    • digit grouping separators: options to enable/disable digit separators -and provide a choice of separator symbol

    • -
    • pattern: option to use a text pattern for decoration of the formatted -values

    • -
    • locale-based formatting: providing a locale ID will result in number -formatting specific to the chosen locale

    • -
    - -
    - -
    fmt_percent(data, columns, rows = NULL, decimals = 2,
    -  drop_trailing_zeros = FALSE, negative_val = "signed",
    -  use_seps = TRUE, pattern = "{x}", sep_mark = ",", dec_mark = ".",
    -  incl_space = FALSE, placement = "right", locale = NULL)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    columns

    the columns to format. Can either be a series of column names -provided in vars(), a vector of column indices, or a helper function -focused on selections. The select helper functions are: -starts_with(), ends_with(), -contains(), matches(), one_of(), -and everything().

    rows

    optional rows to format. Not providing any value results in all -rows in columns being formatted. Can either be a vector of row -captions provided c(), a vector of row indices, or a helper function -focused on selections. The select helper functions are: -starts_with(), ends_with(), -contains(), matches(), one_of(), -and everything(). We can also use expressions to filter down -to the rows we need (e.g., [colname_1] > 100 & [colname_2] < 50).

    decimals

    an option to specify the exact number of decimal places to -use. The default number of decimal places is 2.

    drop_trailing_zeros

    a logical value that allows for removal of -trailing zeros (those redundant zeros after the decimal mark).

    negative_val

    the formatting to use for negative values. With -signed (the default), negative values will be shown with a negative -sign. Using parens will show the negative value in parentheses.

    use_seps

    an option to use digit group separators. The type of digit -group separator is set by sep_mark and overridden if a locale ID is -provided to locale. This setting is TRUE by default.

    pattern

    a formatting pattern that allows for decoration of the -formatted value. The value itself is represented by {x} and all -other characters are taken to be string literals.

    sep_mark

    the mark to use as a separator between groups of digits -(e.g., using sep_mark = "," with 1000 would result in a -formatted value of 1,000).

    dec_mark

    the character to use as a decimal mark (e.g., using -dec_mark = "," with 0.152 would result in a formatted value -of 0,152).

    incl_space

    an option on whether to include a space between the value -and the percent sign. The default is to not introduce a space character.

    placement

    the placement of the percent sign. This can be either be -right (the default) or left.

    locale

    an optional locale ID that can be used for formatting the value -according the locale's rules. Examples include "en_US" for English -(United States) and "fr_FR" for French (France). The use of a valid -locale ID will override any values provided in sep_mark and -dec_mark.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Details

    - -

    Targeting of values is done through columns and additionally by -rows (if nothing is provided for rows then entire columns are -selected). A number of helper functions exist to make targeting more -effective. Conditional formatting is possible by providing a conditional -expression to the rows argument. See the Arguments section for more -information on this.

    - -

    Figures

    - - -

    - -

    See also

    - - - - -

    Examples

    -
    # Use `exibble` to create a gt table; -# format the `num` column to have -# percentage values in the first five -# of its rows -tab_1 <- - exibble %>% - gt() %>% - fmt_percent( - columns = vars(num), - rows = 1:5, - decimals = 1, - drop_trailing_zeros = TRUE - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/fmt_scientific.html b/docs/reference/fmt_scientific.html deleted file mode 100644 index b0a64ae8bd..0000000000 --- a/docs/reference/fmt_scientific.html +++ /dev/null @@ -1,319 +0,0 @@ - - - - - - - - -Format values to scientific notation ā€” fmt_scientific ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    With numeric values in a gt table, we can perform formatting so that -the targeted values are presented in scientific notation. We can exert finer -finer control on the formatting with the following options:

      -
    • decimals: choice of the number of decimal places, option to drop -trailing zeros, and a choice of the decimal symbol

    • -
    • scaling: we can choose to scale targeted values by a multiplier value

    • -
    • pattern: option to use a text pattern for decoration of the formatted -values

    • -
    • locale-based formatting: providing a locale ID will result in -formatting specific to the chosen locale

    • -
    - -
    - -
    fmt_scientific(data, columns, rows = NULL, decimals = 2,
    -  drop_trailing_zeros = FALSE, scale_by = 1, pattern = "{x}",
    -  sep_mark = ",", dec_mark = ".", locale = NULL)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    columns

    the columns to format. Can either be a series of column names -provided in vars(), a vector of column indices, or a helper function -focused on selections. The select helper functions are: -starts_with(), ends_with(), -contains(), matches(), one_of(), -and everything().

    rows

    optional rows to format. Not providing any value results in all -rows in columns being formatted. Can either be a vector of row -captions provided c(), a vector of row indices, or a helper function -focused on selections. The select helper functions are: -starts_with(), ends_with(), -contains(), matches(), one_of(), -and everything(). We can also use expressions to filter down -to the rows we need (e.g., [colname_1] > 100 & [colname_2] < 50).

    decimals

    an option to specify the exact number of decimal places to -use. The default number of decimal places is 2.

    drop_trailing_zeros

    a logical value that allows for removal of -trailing zeros (those redundant zeros after the decimal mark).

    scale_by

    a value to scale the input. The default is 1.0.

    pattern

    a formatting pattern that allows for decoration of the -formatted value. The value itself is represented by {x} and all -other characters are taken to be string literals.

    sep_mark

    the mark to use as a separator between groups of digits -(e.g., using sep_mark = "," with 1000 would result in a -formatted value of 1,000).

    dec_mark

    the character to use as a decimal mark (e.g., using -dec_mark = "," with 0.152 would result in a formatted value -of 0,152).

    locale

    an optional locale ID that can be used for formatting the value -according the locale's rules. Examples include "en_US" for English -(United States) and "fr_FR" for French (France). The use of a valid -locale ID will override any values provided in sep_mark and -dec_mark.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Details

    - -

    Targeting of values is done through columns and additionally by -rows (if nothing is provided for rows then entire columns are -selected). A number of helper functions exist to make targeting more -effective. Conditional formatting is possible by providing a conditional -expression to the rows argument. See the Arguments section for more -information on this.

    - -

    Figures

    - - -

    - -

    See also

    - - - - -

    Examples

    -
    # Use `exibble` to create a gt table; -# format the `num` column as partially -# numeric and partially in scientific -# notation -tab_1 <- - exibble %>% - gt() %>% - fmt_number( - columns = vars(num), - rows = num > 500, - decimals = 1, - scale_by = 1/1000, - pattern = "{x}K" - ) %>% - fmt_scientific( - columns = vars(num), - rows = num <= 500, - decimals = 1 - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/fmt_time.html b/docs/reference/fmt_time.html deleted file mode 100644 index 1ea7970264..0000000000 --- a/docs/reference/fmt_time.html +++ /dev/null @@ -1,294 +0,0 @@ - - - - - - - - -Format values as times ā€” fmt_time ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Format input time values that are character-based and expressed according to -the ISO 8601 time format (HH:MM:SS). Once the appropriate data cells -are targeted with columns (and, optionally, rows), we can -simply apply a preset time style (see table in -info_time_style() for info) to format the times.

    - -
    - -
    fmt_time(data, columns, rows = NULL, time_style = 2)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    columns

    the columns to format. Can either be a series of column names -provided in vars(), a vector of column indices, or a helper function -focused on selections. The select helper functions are: -starts_with(), ends_with(), -contains(), matches(), one_of(), -and everything().

    rows

    optional rows to format. Not providing any value results in all -rows in columns being formatted. Can either be a vector of row -captions provided c(), a vector of row indices, or a helper function -focused on selections. The select helper functions are: -starts_with(), ends_with(), -contains(), matches(), one_of(), -and everything(). We can also use expressions to filter down -to the rows we need (e.g., [colname_1] > 100 & [colname_2] < 50).

    time_style

    the time style to use. Supply a number (from 1 to -5) that corresponds to the preferred time style. Use -info_time_style() to see the different numbered and named time -presets.

    - -

    Details

    - -

    The following time styles are available for simpler formatting of ISO times -(all using the input time of 14:35:00 in the example output times):

    -
      -
    1. hms: 14:35:00

    2. -
    3. hm: 14:35

    4. -
    5. hms_p: 2:35:00 PM

    6. -
    7. hm_p: 2:35 PM

    8. -
    9. h_p: 2 PM

    10. -
    -

    We can use the info_time_style() function for a useful -reference on all of the possible inputs to time_style.

    -

    Targeting of values is done through columns and additionally by -rows (if nothing is provided for rows then entire columns are -selected). A number of helper functions exist to make targeting more -effective. Conditional formatting is possible by providing a conditional -expression to the rows argument. See the Arguments section for more -information on this.

    - -

    Figures

    - - -

    -

    - -

    See also

    - - - - -

    Examples

    -
    # Use `exibble` to create a gt table; -# keep only the `date` and `time` columns; -# format the `time` column to have -# times formatted as `hms_p` -# (time style `3`) -tab_1 <- - exibble %>% - dplyr::select(date, time) %>% - gt() %>% - fmt_time( - columns = vars(time), - time_style = 3 - ) - -# Use `exibble` to create a gt table; -# keep only the `date` and `time` columns; -# format the `time` column to have mixed -# time formats (times after 16:00 will -# be different than the others) -tab_2 <- - exibble %>% - dplyr::select(date, time) %>% - gt() %>% - fmt_time( - columns = vars(time), - rows = - time > "16:00", - time_style = 3 - ) %>% - fmt_time( - columns = vars(time), - rows = - time <= "16:00", - time_style = 4 - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/ggplot_image.html b/docs/reference/ggplot_image.html deleted file mode 100644 index fa25cb6f82..0000000000 --- a/docs/reference/ggplot_image.html +++ /dev/null @@ -1,281 +0,0 @@ - - - - - - - - -Helper function for adding a ggplot ā€” ggplot_image ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    We can add a ggplot2 plot inside of a table with the help of the -ggplot_image() function. The function provides a convenient way to -generate an HTML fragment with a ggplot object. Because this function -is currently HTML-based, it is only useful for HTML table output. To use this -function inside of data cells, it is recommended that the -text_transform() function is used. With that function, we can -specify which data cells to target and then include a call to -ggplot_image() within the required user-defined function (for the -fn argument). If we want to include a plot in other places (e.g., in -the header, within footnote text, etc.) we need to use ggplot_image() -within the html() helper function.

    - -
    - -
    ggplot_image(plot_object, height = 100, aspect_ratio = 1)
    - -

    Arguments

    - - - - - - - - - - - - - - -
    plot_object

    a ggplot plot object.

    height

    the absolute height (px) of the image in the table cell.

    aspect_ratio

    the plot's final aspect ratio. Where the height of the -plot is fixed using the height argument, the aspect_ratio -will either compress (aspect_ratio < 1.0) or expand -(aspect_ratio > 1.0) the plot horizontally. The default value -of 1.0 will neither compress nor expand the plot.

    - -

    Value

    - -

    a character object with an HTML fragment that can be placed inside of - a cell.

    - -

    Details

    - -

    By itself, the function creates an HTML image tag with an image URI embedded -within (a 100 dpi PNG). We can easily experiment with any ggplot2 plot -object, and using it within ggplot_image(plot_object = <plot object> -evaluates to:

    -

    <img cid=<random CID> src=<data URI> style=\"height:100px;\">

    -

    where a height of 100px is a default height chosen to work well within -the heights of most table rows. There is the option to modify the aspect -ratio of the plot (the default aspect_ratio is 1.0) and this is -useful for elongating any given plot to fit better within the table -construct.

    - -

    Figures

    - - -

    - -

    See also

    - -

    Other image addition functions: local_image, - test_image, web_image

    - - -

    Examples

    -
    library(ggplot2) - -# Create a ggplot plot -plot_object <- - ggplot( - data = gtcars, - aes(x = hp, y = trq, - size = msrp)) + - geom_point(color = "blue") + - theme(legend.position = "none") - -# Create a tibble that contains two -# cells (where one is a placeholder for -# an image), then, create a gt table; -# use the `text_transform()` function -# to insert the plot using by calling -# `ggplot_object()` within the user- -# defined function -tab_1 <- - dplyr::tibble( - text = "Here is a ggplot:", - ggplot = NA - ) %>% - gt() %>% - text_transform( - locations = cells_data(vars(ggplot)), - fn = function(x) { - plot_object %>% - ggplot_image(height = px(200)) - } - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/gt-options.html b/docs/reference/gt-options.html deleted file mode 100644 index a3c32c9b94..0000000000 --- a/docs/reference/gt-options.html +++ /dev/null @@ -1,179 +0,0 @@ - - - - - - - - -<span class="pkg">gt</span> package options ā€” gt-options ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -gt package options ā€” gt-options" /> - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    gt package options

    - -
    - - -

    Package options

    - - -

    gt uses the following options to configure behavior:

    -
      -
    • gt.stub_group.sep: a separator between groups for the - stub group label.

    • -
    - - -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/gt-package.html b/docs/reference/gt-package.html deleted file mode 100644 index 13a5e0acdb..0000000000 --- a/docs/reference/gt-package.html +++ /dev/null @@ -1,195 +0,0 @@ - - - - - - - - -gt: Easily Create Presentation-Ready Display Tables ā€” gt-package ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Build display tables from tabular data using with an easy-to-use - API. With its progressive approach, we can construct display tables with a - clear separation of concerns: you don't have to decide how the tabular data - gets transformed and structured whilst also worrying about aesthetics.

    - -
    - - -

    See also

    - - - - -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/gt.html b/docs/reference/gt.html deleted file mode 100644 index 2b7efd5a74..0000000000 --- a/docs/reference/gt.html +++ /dev/null @@ -1,280 +0,0 @@ - - - - - - - - -Create a <span class="pkg">gt</span> table object ā€” gt ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -gt table object ā€” gt" /> - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    The gt() function creates a gt table object when provided with -table data. Using this function is the first step in a typical gt -workflow. Once we have the gt table object, we can perform styling -transformations before rendering to a display table of various formats (e.g., -HTML, LaTeX, RTF).

    - -
    - -
    gt(data, rowname_col = "rowname", groupname_col = "groupname",
    -  rownames_to_stub = FALSE,
    -  stub_group.sep = getOption("gt.stub_group.sep", " - "))
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - -
    data

    a data.frame object or a tibble.

    rowname_col

    the column name in the input data table to use as -row captions to be placed in the display table stub.

    groupname_col

    the column name in the input data table to use as -group labels for generation of stub row groups.

    rownames_to_stub

    an option to take rownames from the input data -table as row captions in the display table stub.

    stub_group.sep

    the separator to use between consecutive group names (a -possibility when providing data as a grouped_df with multiple -groups) in the displayed stub row group label.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Details

    - -

    There are a few data ingest options we can consider at this stage. We can -choose to create a table stub with rowname captions using the -rowname_col argument. Further to this, stub row groups can be created -with the groupname_col. Both arguments take the name of a column in -the input table data. Typically, the data in the groupname_col will -consist of categories of data in a table and the data in the -rowname_col are unique labels (perhaps unique across the entire table -or unique within groups).

    -

    Row groups can also be created by passing a grouped_df to gt() -by using the dplyr::group_by() function on the table data. In this -way, two or more columns of categorical data can be used to make row groups. -The stub_group.sep argument allows for control in how the row group -label will appear in the display table.

    - -

    Figures

    - - -

    -

    - -

    See also

    - -

    Other table-part creation/modification functions: gt_preview, - tab_footnote, tab_header, - tab_options, tab_row_group, - tab_source_note, tab_spanner, - tab_stubhead_label, tab_style

    - - -

    Examples

    -
    # Create a table object using the -# `exibble` dataset; use the `row` -# and `group` columns to add a stub -# and row groups -tab_1 <- - exibble %>% - gt( - rowname_col = "row", - groupname_col = "group" - ) - -# The resulting object can be used -# in transformations (with `tab_*()`, -# `fmt_*()`, `cols_*()` functions) -tab_2 <- - tab_1 %>% - tab_header( - title = "Table Title", - subtitle = "Subtitle" - ) %>% - fmt_number( - columns = vars(num), - decimals = 2 - ) %>% - cols_label(num = "number")
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/gt_latex_dependencies.html b/docs/reference/gt_latex_dependencies.html deleted file mode 100644 index 97255fbf2d..0000000000 --- a/docs/reference/gt_latex_dependencies.html +++ /dev/null @@ -1,212 +0,0 @@ - - - - - - - - -Get the LaTeX dependencies required for a gt table ā€” gt_latex_dependencies ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    When working with Rnw (Sweave) files or otherwise writing LaTeX code, -including a gt table can be problematic if we don't have knowledge -of the LaTeX dependencies. For the most part, these dependencies are the -LaTeX packages that are required for rendering a gt table. The -gt_latex_dependencies() function provides an object that can be -used to provide the LaTeX in an Rnw file, allowing gt tables to work -and not yield errors due to missing packages.

    - -
    - -
    gt_latex_dependencies()
    - -

    Details

    - -

    Here is an example Rnw document that shows how the -gt_latex_dependencies() can be used in conjunction with a gt -table:

    -
    -%!sweave=knitr
    -    \documentclass{article}
    -    <<echo=FALSE>>=
    -library(gt)
    - @
    -    <<results='asis', echo=FALSE>>=
    -gt_latex_dependencies()
    - @
    -    \begin{document}
    -    <<results='asis', echo=FALSE>>=
    -exibble 
    - @
    -    \end{document}
    -
    - -

    See also

    - -

    Other helper functions: cells_styles, - escape_latex, html, - md, pct, px

    - - -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/gt_output.html b/docs/reference/gt_output.html deleted file mode 100644 index 0c6f4034f8..0000000000 --- a/docs/reference/gt_output.html +++ /dev/null @@ -1,192 +0,0 @@ - - - - - - - - -Create a <span class="pkg">gt</span> display table output element for Shiny ā€” gt_output ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -gt display table output element for Shiny ā€” gt_output" /> - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Create a gt display table output element for Shiny

    - -
    - -
    gt_output(outputId)
    - -

    Arguments

    - - - - - - -
    outputId

    an output variable from which to read the table.

    - -

    Value

    - -

    A gt table output element that can be included in a panel.

    - -

    See also

    - -

    render_gt()

    -

    Other Shiny functions: render_gt

    - - -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/gt_preview.html b/docs/reference/gt_preview.html deleted file mode 100644 index 3fc9f8b34d..0000000000 --- a/docs/reference/gt_preview.html +++ /dev/null @@ -1,253 +0,0 @@ - - - - - - - - -Preview a <span class="pkg">gt</span> table object ā€” gt_preview ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -gt table object ā€” gt_preview" /> - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Sometimes you may want to see just a small portion of your input data. We can -use gt_preview() in place of gt() to get the first x -rows of data and the last y rows of data (which can be set by the -top_n and bottom_n arguments). It's not advised to use -additional gt API functions to further modify the output of -gt_preview(). Furthermore, you cannot pass a gt object to -gt_preview().

    - -
    - -
    gt_preview(data, top_n = 5, bottom_n = 1, incl_rownums = TRUE)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - -
    data

    a data.frame object or a tibble.

    top_n

    this value will be used as the number of rows from the top of -the table to display. The default, 5, will show the first five rows -of the table.

    bottom_n

    the value will be used as the number of rows from the bottom -of the table to display. The default, 1, will show the final row of -the table.

    incl_rownums

    an option to include the row numbers for data in -the table stub. By default, this is TRUE.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Details

    - -

    Any grouped data or magic columns such as rowname and groupname -will be ignored by gt_preview() and, as such, one cannot add a stub or -group rows in the output table. By default, the output table will include row -numbers in a stub (including a range of row numbers for the omitted rows). -This row numbering option can be deactivated by setting incl_rownums -to FALSE.

    - -

    Figures

    - - -

    - -

    See also

    - -

    Other table-part creation/modification functions: gt, - tab_footnote, tab_header, - tab_options, tab_row_group, - tab_source_note, tab_spanner, - tab_stubhead_label, tab_style

    - - -

    Examples

    -
    # Use `gtcars` to create a gt table -# preview (with only a few of its -# columns); you'll see the first five -# rows and the last row -tab_1 <- - gtcars %>% - dplyr::select(mfr, model, year) %>% - gt_preview()
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/gtcars.html b/docs/reference/gtcars.html deleted file mode 100644 index 4fd71737df..0000000000 --- a/docs/reference/gtcars.html +++ /dev/null @@ -1,230 +0,0 @@ - - - - - - - - -Deluxe automobiles from the 2014-2017 period ā€” gtcars ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Expensive and fast cars. Not your father's mtcars. Each row describes -a car of a certain make, model, year, and trim. Basic specifications such as -horsepower, torque, EPA MPG ratings, type of drivetrain, and transmission -characteristics are provided. The country of origin for the car manufacturer -is also given.

    - -
    - -
    gtcars
    - -

    Format

    - -

    A tibble with 47 rows and 15 variables:

    -
    mfr

    The name of the car manufacturer

    -
    model

    The car's model name

    -
    year

    The car's model year

    -
    trim

    A short description of the car model's trim

    -
    bdy_style

    An identifier of the car's body style, which is either - coupe, convertible, sedan, or hatchback

    -
    hp, hp_rpm

    The car's horsepower and the associated RPM level

    -
    trq, trq_rpm

    The car's torque and the associated RPM level

    -
    mpg_c, mpg_h

    The miles per gallon fuel efficiency rating for city - and highway driving

    -
    drivetrain

    The car's drivetrain which, for this dataset is either - rwd (Rear Wheel Drive) or awd (All Wheel Drive)

    -
    trsmn

    The codified transmission type, where the number part is - the number of gears; the car could have automatic transmission - (a), manual transmission (m), an option to switch between - both types (am), or, direct drive (dd)

    -
    ctry_origin

    The country name for where the vehicle manufacturer - is headquartered

    -
    - -

    Source

    - -

    Various pages within https://www.edmunds.com.

    - - -

    Examples

    -
    # Here is a glimpse at the data -# available in `gtcars` -dplyr::glimpse(gtcars)
    #> Observations: 47 -#> Variables: 15 -#> $ mfr <chr> "Ford", "Ferrari", "Ferrari", "Ferrari", "Ferrari", "Ferrā€¦ -#> $ model <chr> "GT", "458 Speciale", "458 Spider", "458 Italia", "488 GTā€¦ -#> $ year <dbl> 2017, 2015, 2015, 2014, 2016, 2015, 2017, 2015, 2015, 201ā€¦ -#> $ trim <chr> "Base Coupe", "Base Coupe", "Base", "Base Coupe", "Base Cā€¦ -#> $ bdy_style <chr> "coupe", "coupe", "convertible", "coupe", "coupe", "conveā€¦ -#> $ hp <dbl> 647, 597, 562, 562, 661, 553, 680, 652, 731, 949, 573, 54ā€¦ -#> $ hp_rpm <dbl> 6250, 9000, 9000, 9000, 8000, 7500, 8250, 8000, 8250, 900ā€¦ -#> $ trq <dbl> 550, 398, 398, 398, 561, 557, 514, 504, 509, 664, 476, 43ā€¦ -#> $ trq_rpm <dbl> 5900, 6000, 6000, 6000, 3000, 4750, 5750, 6000, 6000, 675ā€¦ -#> $ mpg_c <dbl> 11, 13, 13, 13, 15, 16, 12, 11, 11, 12, 21, 16, 11, 16, 1ā€¦ -#> $ mpg_h <dbl> 18, 17, 17, 17, 22, 23, 17, 16, 16, 16, 22, 22, 18, 20, 2ā€¦ -#> $ drivetrain <chr> "rwd", "rwd", "rwd", "rwd", "rwd", "rwd", "awd", "awd", "ā€¦ -#> $ trsmn <chr> "7a", "7a", "7a", "7a", "7a", "7a", "7a", "7a", "7a", "7aā€¦ -#> $ ctry_origin <chr> "United States", "Italy", "Italy", "Italy", "Italy", "Itaā€¦ -#> $ msrp <dbl> 447000, 291744, 263553, 233509, 245400, 198973, 298000, 2ā€¦
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/html.html b/docs/reference/html.html deleted file mode 100644 index 44155fc7e0..0000000000 --- a/docs/reference/html.html +++ /dev/null @@ -1,216 +0,0 @@ - - - - - - - - -Interpret input text as HTML-formatted text ā€” html ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Interpret input text as HTML-formatted text

    - -
    - -
    html(text, ...)
    - -

    Arguments

    - - - - - - -
    text, ...

    the text that is understood to be HTML text, which is to be -preserved.

    - -

    Value

    - -

    a character object that is tagged as an HTML fragment that is not to - be sanitized.

    -

    a character object of class html.

    - -

    Figures

    - - -

    - -

    See also

    - -

    Other helper functions: cells_styles, - escape_latex, - gt_latex_dependencies, md, - pct, px

    - - -

    Examples

    -
    # Use `exibble` to create a gt table; -# when adding a title, use the `html()` -# helper to use html formatting -tab_1 <- - exibble %>% - dplyr::select(currency, char) %>% - gt() %>% - tab_header( - title = html("<em>HTML</em>"))
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/index.html b/docs/reference/index.html deleted file mode 100644 index f446ae2180..0000000000 --- a/docs/reference/index.html +++ /dev/null @@ -1,652 +0,0 @@ - - - - - - - - -Function reference ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -

    Create Table

    -

    RStudio Cloud Example

    All gt tables begin with a call to gt(), where we would supply the input data table (data frame or tibble) and some basic options for creating a stub (rowname_col) and row groups (groupname_col). We can also introduce a grouped tibble (via dplyrā€™s group_by()) for more precise divisions of rows into row groups. The gt_preview() function is great for getting a nicely-formatted preview of a data table (defaulting to the first 5 rows and the last row).

    -
    -

    gt()

    -

    Create a gt table object

    -

    gt_preview()

    -

    Preview a gt table object

    -

    Create/Modify Parts

    -

    RStudio Cloud Example

    A gt table can contain a few useful parts for conveying additional information. These include a header (with a titles and subtitle), a footer (with footnotes and source notes), and additional areas for labels (row group labels, column spanner labels, the stubhead label). We can modify the look of table parts more generally with tab_options() and perform styling on targeted table locations with tab_style()

    -
    -

    tab_header()

    -

    Add a table header

    -

    tab_spanner()

    -

    Add a spanner column label

    -

    tab_row_group()

    -

    Add a row group

    -

    tab_stubhead_label()

    -

    Add label text to the stubhead

    -

    tab_footnote()

    -

    Add a table footnote

    -

    tab_source_note()

    -

    Add a source note citation

    -

    tab_options()

    -

    Modify the table output options

    -

    tab_style()

    -

    Add custom styles to one or more cells

    -

    Format Data

    -

    RStudio Cloud Example

    Columns of data can be formatted with the fmt_*() functions. We can specify the rows of these columns quite precisely with the rows argument. We get to apply these functions exactly once to each data cell (last call wins). Need to do custom formatting? Use the fmt() function and define your own formatter within (or, create a wrapper with fmt() if you prefer). The text_transform() function allows for post-processing of any data, and we provide a function for that transformation.

    -
    -

    fmt()

    -

    Set a column format with a formatter function

    -

    fmt_number()

    -

    Format numeric values

    -

    fmt_scientific()

    -

    Format values to scientific notation

    -

    fmt_percent()

    -

    Format values as a percentage

    -

    fmt_currency()

    -

    Format values as currencies

    -

    fmt_date()

    -

    Format values as dates

    -

    fmt_time()

    -

    Format values as times

    -

    fmt_datetime()

    -

    Format values as date-times

    -

    fmt_missing()

    -

    Format missing values

    -

    fmt_passthrough()

    -

    Format by simply passing data through

    -

    text_transform()

    -

    Perform targeted text transformation with a function

    -

    data_color()

    -

    Set data cell colors using a palette or a color function

    -

    Modify Columns

    -

    RStudio Cloud Example

    The cols_*() functions allow for modifications that act on entire columns. This includes alignment of the data in columns (cols_align()), hiding columns from view (cols_hide()), re-labeling the column labels (cols_label()), merging two columns together (cols_merge*()), moving columns around (cols_move*()), and using a column name delimiter to create labels in the column spanner (cols_split_delim()).

    -
    -

    cols_align()

    -

    Set the alignment of columns

    -

    cols_hide()

    -

    Hide one or more columns

    -

    cols_label()

    -

    Relabel one or more columns

    -

    cols_merge()

    -

    Merge two columns to a single column

    -

    cols_merge_range()

    -

    Merge two columns to a value range column

    -

    cols_merge_uncert()

    -

    Merge two columns to a value & uncertainty column

    -

    cols_move()

    -

    Move one or more columns

    -

    cols_move_to_end()

    -

    Move one or more columns to the end

    -

    cols_move_to_start()

    -

    Move one or more columns to the start

    -

    cols_split_delim()

    -

    Create group names and column labels via delimited names

    -

    Modify Rows

    -

    RStudio Cloud Example

    The only function currently that modifies entire rows is the row_group_order() function. It lets us modify the ordering of any row groups in the table.

    -
    -

    row_group_order()

    -

    Modify the ordering of any row groups

    -

    Add Rows

    -

    RStudio Cloud Example

    There is one function that will add rows to a gt table and that is the summary_rows() function. Itā€™s useful for adding summary rows to any table that has row groups and a stub (which is required for summary row labels).

    -
    -

    summary_rows()

    -

    Add summary rows using aggregation functions

    -

    Export Table

    -

    RStudio Cloud Example

    There may come a day when you need to export a gt table to some specific format. We have functions for getting the HTML content of a gt table (as_raw_html()), getting LaTeX code (as_latex()), and getting rich text (as_rtf()). Did you use the summary_rows() function and wish you had that summary data in a tibble? You can get it out with extract_summary().

    -
    -

    as_raw_html()

    -

    Get the HTML content of a gt table

    -

    as_latex()

    -

    Output a gt object as LaTeX

    -

    as_rtf()

    -

    Output a gt object as RTF

    -

    extract_summary()

    -

    Extract a summary list from a gt object

    -

    Shiny Functions

    -

    Shiny is great for building interactive web apps with R. Thereā€™s really nothing quite like it. The gt package includes two functions that work nicely with Shiny: a table render function render_gt() (for the server) and a table output element gt_output() (for the ui).

    -
    -

    render_gt()

    -

    A gt display table render function for use in Shiny

    -

    gt_output()

    -

    Create a gt display table output element for Shiny

    -

    Helper Functions

    -

    A small assortment of helper functions is available in the gt package. The various cells_*() functions are used for targeting cells with the locations argument in the tab_footnote(), tab_style(), and text_transform() functions. The cells_styles() function is used exclusively with tab_style()ā€™s style argument (and the px() & pct() functions may be useful there for specifying units in pixels or percentages). The md() and html() helpers can used be during label creation with the tab_header(), tab_footnote(), tab_spanner(), tab_stubhead_label(), and tab_source_note() functions.

    -
    -

    cells_title() cells_column_labels() cells_group() cells_stub() cells_data() cells_summary()

    -

    Helpers for targeting multiple cells in different locations

    -

    cells_styles()

    -

    Helper for defining custom styles for table cells

    -

    reexports

    -

    Objects exported from other packages

    -

    md()

    -

    Interpret input text as Markdown-formatted text

    -

    html()

    -

    Interpret input text as HTML-formatted text

    -

    px()

    -

    Helper for providing a numeric value as pixels value

    -

    pct()

    -

    Helper for providing a numeric value as percentage

    -

    escape_latex()

    -

    Perform LaTeX escaping

    -

    adjust_luminance()

    -

    Adjust the luminance for a palette of colors

    -

    Image Addition

    -

    RStudio Cloud Example

    We can add images into a gt table with the help of the *_image() functions. Two common ways to do this: (1) use text_transform() to insert images into data cells, (2) use any function that creates new labels (e.g., tab_header()) and use a *_image() function within the html() helper.

    -
    -

    web_image()

    -

    Helper function for adding an image from the web

    -

    local_image()

    -

    Helper function for adding a local image

    -

    ggplot_image()

    -

    Helper function for adding a ggplot

    -

    test_image()

    -

    Generate a path to a test image

    -

    Information

    -

    These info_*() functions present us with gt tables containing useful information. So far, we can get reference information on date styles (info_date_style()), on time styles (info_time_style()), on a huge number of color palettes (info_paletteer()), and, on currencies (info_currencies()).

    -
    -

    info_date_style()

    -

    View a table with info on date styles

    -

    info_time_style()

    -

    View a table with info on time styles

    -

    info_paletteer()

    -

    View a table with info on many different color palettes

    -

    info_currencies()

    -

    View a table with info on supported currencies

    -

    Datasets

    -

    The gt package is equipped with six datasets. Use them to experiment with the API, they come in all shapes and sizes. Many examples in the internal help documents use these datasets to quickly demonstrate key features of gt.

    -
    -

    countrypops

    -

    Yearly populations of countries from 1960 to 2017

    -

    sza

    -

    Twice hourly solar zenith angles by month & latitude

    -

    gtcars

    -

    Deluxe automobiles from the 2014-2017 period

    -

    sp500

    -

    Daily S&P 500 Index data from 1950 to 2015

    -

    pizzaplace

    -

    A year of pizza sales from a pizza place

    -

    exibble

    -

    A toy example tibble for testing with gt: exibble

    -
    - - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/info_currencies.html b/docs/reference/info_currencies.html deleted file mode 100644 index f5adb61182..0000000000 --- a/docs/reference/info_currencies.html +++ /dev/null @@ -1,239 +0,0 @@ - - - - - - - - -View a table with info on supported currencies ā€” info_currencies ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    The fmt_currency() function lets us format numeric values as -currencies. The table generated by the info_currencies() function -provides a quick reference to all the available currencies. The currency -identifiers are provided (name, 3-letter currency code, and 3-digit currency -code) along with the each currency's exponent value (number of digits of the -currency subunits). A formatted example is provided (based on the value of -49.95) to demonstrate the default formatting of each currency.

    - -
    - -
    info_currencies(type = c("code", "symbol"), begins_with = NULL)
    - -

    Arguments

    - - - - - - - - - - -
    type

    the type of currency information provided. Can either be -code where currency information corresponding to 3-letter currency -codes is provided, or symbol where currency info for common currency -names (e.g., dollar, pound, yen, etc.) is returned.

    begins_with

    providing a single letter will filter currencies to only -those that begin with that letter in their currency code. The default -(NULL) will produce a table with all currencies displayed. This -option only constrains the information table where type == "code".

    - -

    Details

    - -

    There are 172 currencies, which can lead to a verbose display table. To make -this presentation more focused on retrieval, we can provide an initial letter -corresponding to the 3-letter currency code to begins_with. This will -filter currencies in the info table to just the set beginning with the -supplied letter.

    - -

    Figures

    - - -

    -

    - -

    See also

    - -

    Other information functions: info_date_style, - info_paletteer, - info_time_style

    - - -

    Examples

    -
    # Get a table of info on all of -# the currencies where the three- -# letter code begins with a "h" -tab_1 <- info_currencies(begins_with = "h") - -# Get a table of info on all of the -# common currency name/symbols that -# can be used with `fmt_currency()` -tab_2 <- info_currencies(type = "symbol")
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/info_date_style.html b/docs/reference/info_date_style.html deleted file mode 100644 index 30fcc07731..0000000000 --- a/docs/reference/info_date_style.html +++ /dev/null @@ -1,200 +0,0 @@ - - - - - - - - -View a table with info on date styles ā€” info_date_style ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    The fmt_date() function lets us format date-based values in a -convenient manner using preset styles. The table generated by the -info_date_style() function provides a quick reference to all 14 -styles, with associated number codes, the format names, and example outputs -using a fixed date (2000-02-29).

    - -
    - -
    info_date_style()
    - -

    Figures

    - - -

    - -

    See also

    - -

    Other information functions: info_currencies, - info_paletteer, - info_time_style

    - - -

    Examples

    -
    # Get a table of info on the different -# date-formatting styles (which are used -# by supplying a number code to the -# `fmt_date()` function) -tab_1 <- info_date_style()
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/info_paletteer.html b/docs/reference/info_paletteer.html deleted file mode 100644 index fd2fe281a7..0000000000 --- a/docs/reference/info_paletteer.html +++ /dev/null @@ -1,232 +0,0 @@ - - - - - - - - -View a table with info on many different color palettes ā€” info_paletteer ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    While the data_color() function allows us to flexibly color -data cells in our gt table, the harder part of this process is -discovering and choosing color palettes that are suitable for the table -output. We can make this process much easier in two ways: (1) by using the -paletteer package, which makes a wide range of palettes from various R -packages readily available, and (2) calling the info_paletteer() -function to give us an information table that serves as quick reference for -all of the discrete color palettes available in paletteer.

    - -
    - -
    info_paletteer(color_pkgs = NULL)
    - -

    Arguments

    - - - - - - -
    color_pkgs

    a vector of color packages that determines which sets of -palettes should be displayed in the information table. If this is -NULL (the default) then all of the discrete palettes from all of the -color packages represented in paletteer will be displayed.

    - -

    Details

    - -

    The palettes displayed are organized by package and by palette name. These -values are required when obtaining a palette (as a vector of hexadecimal -colors), from the the paletteer::paletteer_d() function. Once we are -familiar with the names of the color palette packages (e.g., -RColorBrewer, ggthemes, wesanderson), we can narrow down -the content of this information table by supplying a vector package names to -color_pkgs.

    - -

    Figures

    - - -

    - -

    See also

    - -

    Other information functions: info_currencies, - info_date_style, - info_time_style

    - - -

    Examples

    -
    # Get a table of info on just the -# `ggthemes` color palette (easily -# accessible from the paletteer pkg) -tab_1 <- - info_paletteer( - color_pkgs = "ggthemes")
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/info_time_style.html b/docs/reference/info_time_style.html deleted file mode 100644 index ee8334fe1f..0000000000 --- a/docs/reference/info_time_style.html +++ /dev/null @@ -1,200 +0,0 @@ - - - - - - - - -View a table with info on time styles ā€” info_time_style ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    The fmt_time() function lets us format time-based values in a -convenient manner using preset styles. The table generated by the -info_time_style() function provides a quick reference to all five -styles, with associated number codes, the format names, and example outputs -using a fixed time (14:35).

    - -
    - -
    info_time_style()
    - -

    Figures

    - - -

    - -

    See also

    - -

    Other information functions: info_currencies, - info_date_style, - info_paletteer

    - - -

    Examples

    -
    # Get a table of info on the different -# time-formatting styles (which are used -# by supplying a number code to the -# `fmt_time()` function) -tab_1 <- info_time_style()
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/knit_print.gt_tbl.html b/docs/reference/knit_print.gt_tbl.html deleted file mode 100644 index 0592d0a52e..0000000000 --- a/docs/reference/knit_print.gt_tbl.html +++ /dev/null @@ -1,179 +0,0 @@ - - - - - - - - -Knit print the table ā€” knit_print.gt_tbl ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    This facilitates printing of the HTML table within a knitr code chunk.

    - -
    - -
    knit_print.gt_tbl(x, ...)
    - -

    Arguments

    - - - - - - -
    x

    an object of class gt_tbl.

    - - -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/local_image.html b/docs/reference/local_image.html deleted file mode 100644 index 1ee4d4fe8c..0000000000 --- a/docs/reference/local_image.html +++ /dev/null @@ -1,262 +0,0 @@ - - - - - - - - -Helper function for adding a local image ā€” local_image ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    We can flexibly add a local image (i.e., an image residing on disk) inside of -a table with local_image() function. The function provides a -convenient way to generate an HTML fragment using an on-disk PNG or SVG. -Because this function is currently HTML-based, it is only useful for HTML -table output. To use this function inside of data cells, it is recommended -that the text_transform() function is used. With that function, -we can specify which data cells to target and then include a -local_image() call within the required user-defined function (for the -fn argument). If we want to include an image in other places (e.g., in -the header, within footnote text, etc.) we need to use local_image() -within the html() helper function.

    - -
    - -
    local_image(file, height = 30)
    - -

    Arguments

    - - - - - - - - - - -
    file

    a path to an image file.

    height

    the absolute height (px) of the image in the table cell.

    - -

    Value

    - -

    a character object with an HTML fragment that can be placed inside of - a cell.

    - -

    Details

    - -

    By itself, the function creates an HTML image tag with an image URI embedded -within. We can easily experiment with a local PNG or SVG image that's -available in the gt package using the test_image() -function. Using that, the call local_image(file = test_image(type = -"png")) evaluates to:

    -

    <img cid=<random CID> src=<data URI> style=\"height:30px;\">

    -

    where a height of 30px is a default height chosen to work well within -the heights of most table rows.

    - -

    Figures

    - - -

    - -

    See also

    - -

    Other image addition functions: ggplot_image, - test_image, web_image

    - - -

    Examples

    -
    # Create a tibble that contains heights -# of an image in pixels (one column as a -# string, the other as numerical values), -# then, create a gt table; use the -# `text_transform()` function to insert -# a local test image (PNG) image with the -# various sizes -tab_1 <- - dplyr::tibble( - pixels = px(seq(10, 35, 5)), - image = seq(10, 35, 5) - ) %>% - gt() %>% - text_transform( - locations = cells_data(vars(image)), - fn = function(x) { - local_image( - file = test_image(type = "png"), - height = as.numeric(x) - ) - } - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/location_cells.html b/docs/reference/location_cells.html deleted file mode 100644 index e42c9f357a..0000000000 --- a/docs/reference/location_cells.html +++ /dev/null @@ -1,413 +0,0 @@ - - - - - - - - -Helpers for targeting multiple cells in different locations ā€” location_cells ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    These helper functions are used to target individual cells in different -locations (e.g., the stub, the column labels, the title, etc.). They can be -used in any of these functions (which all have a locations argument): -tab_footnote(), tab_style(), and -text_transform() Furthermore, multiple locations can be -targeted by enclosing several cells_*() helper functions in a list.

    - -
    - -
    cells_title(groups = c("title", "subtitle"))
    -
    -cells_column_labels(columns, groups)
    -
    -cells_group(groups)
    -
    -cells_stub(rows = NULL)
    -
    -cells_data(columns = NULL, rows = NULL)
    -
    -cells_summary(groups = NULL, columns = NULL, rows = NULL)
    - -

    Arguments

    - - - - - - -
    columns, rows, groups

    either a vector of names, a vector of -indices, values provided by vars(), values provided by -c(), or a select helper function (see Details for information on -these functions).

    - -

    Value

    - -

    a list object of class location_cells.

    - -

    Details

    - -

    The following helper functions can be used to target cells (roughly in order -from the top to the bottom of a table):

    -
      -
    • cells_title(): targets the table title or the table subtitle -depending on the value given to the groups argument ("title" or -"subtitle").

    • -
    • cells_column_labels(): targets labels in the column labels (the -columns argument) or the spanner column labels (the groups -argument) in the table's column labels part.

    • -
    • cells_group(): targets the row group labels in any available -row groups using the groups argument.

    • -
    • cells_stub(): targets row labels in the table stub using the -rows argument.

    • -
    • cells_data(): targets data cells in the table field using -intersections of columns and rows.

    • -
    • cells_summary(): targets summary cells in the table field using -the groups argument and intersections of columns and -rows.

    • -
    - -

    Figures

    - - -

    -

    -

    -

    -

    -

    - - -

    Examples

    -
    # Use `sp500` to create a gt table; add -# a header (with a title and a subtitle), -# and then add a footnote to the subtitle -# with `tab_footnote()` and `cells_title()` -# in `locations` -tab_1 <- - sp500 %>% - dplyr::filter( - date >= "2015-01-05" & - date <="2015-01-10" - ) %>% - dplyr::select( - -c(adj_close, volume, high, low) - ) %>% - gt() %>% - tab_header( - title = "S&P 500", - subtitle = "Open and Close Values" - ) %>% - tab_footnote( - footnote = "All values in USD.", - locations = cells_title( - groups = "subtitle") - ) - -# Use `sza` to create a gt table; add a -# header and then add footnotes to the -# column labels with `tab_footnote()` and -# `cells_column_labels()` in `locations` -tab_2 <- - sza %>% - dplyr::filter( - latitude == 20 & month == "jan" & - !is.na(sza) - ) %>% - dplyr::select(-latitude, -month) %>% - gt() %>% - tab_footnote( - footnote = "True solar time.", - locations = cells_column_labels( - columns = vars(tst)) - ) %>% - tab_footnote( - footnote = "Solar zenith angle.", - locations = cells_column_labels( - columns = vars(sza)) - ) - -# Use `pizzaplace` to create a gt table -# with grouped data; add a summary with the -# `summary_rows()` function and then add a -# footnote to the "peppr_salami" row group -# label with `tab_footnote()` and with -# `cells_group()` in `locations` -tab_3 <- - pizzaplace %>% - dplyr::filter( - name %in% c("soppressata", "peppr_salami") - ) %>% - dplyr::group_by(name, size) %>% - dplyr::summarize( - `Pizzas Sold` = n() - ) %>% - gt(rowname_col = "size") %>% - summary_rows( - groups = TRUE, - columns = vars("Pizzas Sold"), - fns = list(TOTAL = "sum"), - formatter = fmt_number, - decimals = 0, - use_seps = TRUE - ) %>% - tab_footnote( - footnote = "The Pepper-Salami.", - cells_group(groups = "peppr_salami") - ) - -# Use `sza` to create a gt table; color -# all of the `month` values in the table -# stub with `tab_style()`, using `cells_stub()` -# in `locations` (`rows = TRUE` targets -# all stub rows) -tab_4 <- - sza %>% - dplyr::filter( - latitude == 20 & tst <= "1000") %>% - dplyr::select(-latitude) %>% - dplyr::filter(!is.na(sza)) %>% - tidyr::spread(key = "tst", value = sza) %>% - gt(rowname_col = "month") %>% - fmt_missing( - columns = TRUE, - missing_text = "" - ) %>% - tab_style( - style = cells_styles( - bkgd_color = "darkblue", - text_color = "white"), - locations = cells_stub(rows = TRUE) - ) - -# Use `gtcars` to create a gt table; add -# a footnote that targets a single data cell -# with `tab_footnote()`, using `cells_data()` -# in `locations` (`rows = hp == max(hp)` will -# target a single row in the `hp` column) -tab_5 <- - gtcars %>% - dplyr::filter(ctry_origin == "United Kingdom") %>% - dplyr::select(mfr, model, year, hp) %>% - gt() %>% - tab_options(footnote.glyph = "*") %>% - tab_footnote( - footnote = "Highest horsepower.", - locations = cells_data( - columns = vars(hp), - rows = hp == max(hp)) - ) - -# Use `countrypops` to create a gt table; add -# some styling to the summary data cells with -# with `tab_style()`, using `cells_summary()` -# in `locations` -tab_6 <- - countrypops %>% - dplyr::filter( - country_name == "Japan", - year < 1970) %>% - dplyr::select(-contains("country")) %>% - dplyr::mutate( - decade = paste0(substr(year, 1, 3), "0s") - ) %>% - dplyr::group_by(decade) %>% - gt( - rowname_col = "year", - groupname_col = "decade" - ) %>% - fmt_number( - columns = vars(population), - decimals = 0 - ) %>% - summary_rows( - groups = "1960s", - columns = vars(population), - fns = list("min", "max"), - formatter = fmt_number, - decimals = 0 - ) %>% - tab_style( - style = cells_styles( - text_style = "italic", - bkgd_color = "lightblue"), - locations = cells_summary( - groups = "1960s", - columns = vars(population), - rows = 1) - ) %>% - tab_style( - style = cells_styles( - text_style = "italic", - bkgd_color = "lightgreen"), - locations = cells_summary( - groups = "1960s", - columns = vars(population), - rows = 2) - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/md.html b/docs/reference/md.html deleted file mode 100644 index 3308100c55..0000000000 --- a/docs/reference/md.html +++ /dev/null @@ -1,215 +0,0 @@ - - - - - - - - -Interpret input text as Markdown-formatted text ā€” md ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Interpret input text as Markdown-formatted text

    - -
    - -
    md(text)
    - -

    Arguments

    - - - - - - -
    text

    the text that is understood to contain Markdown formatting.

    - -

    Value

    - -

    a character object that is tagged for a Markdown-to-HTML - transformation.

    -

    a character object of class from_markdown.

    - -

    Figures

    - - -

    - -

    See also

    - -

    Other helper functions: cells_styles, - escape_latex, - gt_latex_dependencies, html, - pct, px

    - - -

    Examples

    -
    # Use `exibble` to create a gt table; -# when adding a title, use the `md()` -# helper to use Markdown formatting -tab_1 <- - exibble %>% - dplyr::select(currency, char) %>% - gt() %>% - tab_header( - title = md("Using *Markdown*"))
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/pct.html b/docs/reference/pct.html deleted file mode 100644 index 6eb8eaf924..0000000000 --- a/docs/reference/pct.html +++ /dev/null @@ -1,190 +0,0 @@ - - - - - - - - -Helper for providing a numeric value as percentage ā€” pct ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Helper for providing a numeric value as percentage

    - -
    - -
    pct(x)
    - -

    Arguments

    - - - - - - -
    x

    the numeric value to format as a string percentage for some -tab_options() arguments that can take percentage values -(e.g., table.width).

    - -

    See also

    - -

    Other helper functions: cells_styles, - escape_latex, - gt_latex_dependencies, html, - md, px

    - - -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/pipe.html b/docs/reference/pipe.html deleted file mode 100644 index 2560f298cb..0000000000 --- a/docs/reference/pipe.html +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - - - -Pipe operator ā€” %>% ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    See magrittr::%>% for details.

    - -
    - -
    lhs %>% rhs
    - - -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/pizzaplace.html b/docs/reference/pizzaplace.html deleted file mode 100644 index cabf22ab3d..0000000000 --- a/docs/reference/pizzaplace.html +++ /dev/null @@ -1,302 +0,0 @@ - - - - - - - - -A year of pizza sales from a pizza place ā€” pizzaplace ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    A synthetic dataset that describes pizza sales for a pizza place somewhere in -the US. While the contents are artificial, the ingredients used to make the -pizzas are far from it. There are 32 different pizzas that fall into 4 -different categories: classic (classic pizzas: 'You probably had one -like it before, but never like this!'), chicken (pizzas with chicken -as a major ingredient: 'Try the Southwest Chicken Pizza! You'll love it!'), -supreme (pizzas that try a little harder: 'My Soppressata pizza uses -only the finest salami from my personal salumist!'), and, veggie -(pizzas without any meats whatsoever: 'My Five Cheese pizza has so many -cheeses, I can only offer it in Large Size!').

    - -
    - -
    pizzaplace
    - -

    Format

    - -

    A tibble with 49574 rows and 7 variables:

    -
    id

    The ID for the order, which consists of one or more pizzas - at a give date and time

    -
    date

    A character representation of the order date, - expressed in the ISO 8601 date format (YYYY-MM-DD)

    -
    time

    A character representation of the order time, - expressed as a 24-hour time the ISO 8601 extended time format - (hh:mm:ss)

    -
    name

    The short name for the pizza

    -
    size

    The size of the pizza, which can either be S, - M, L, XL (rare!), or XXL (even rarer!); - most pizzas are available in the S, M, and L sizes - but exceptions apply

    -
    type

    The category or type of pizza, which can either be - classic, chicken, supreme, or veggie

    -
    price

    The price of the pizza and the amount that it sold for - (in USD)

    -
    - -

    Details

    - -

    Each pizza in the dataset is identified by a short name. The following -listings provide the full names of each pizza and their main ingredients.

    -

    Classic Pizzas:

      -
    • classic_dlx: The Classic Deluxe Pizza (Pepperoni, Mushrooms, Red -Onions, Red Peppers, Bacon)

    • -
    • big_meat: The Big Meat Pizza (Bacon, Pepperoni, Italian Sausage, -Chorizo Sausage)

    • -
    • pepperoni: The Pepperoni Pizza (Mozzarella Cheese, Pepperoni)

    • -
    • hawaiian: The Hawaiian Pizza (Sliced Ham, Pineapple, Mozzarella -Cheese)

    • -
    • pep_msh_pep: The Pepperoni, Mushroom, and Peppers Pizza -(Pepperoni, Mushrooms, and Green Peppers)

    • -
    • ital_cpcllo: The Italian Capocollo Pizza (Capocollo, Red -Peppers, Tomatoes, Goat Cheese, Garlic, Oregano)

    • -
    • napolitana: The Napolitana Pizza (Tomatoes, Anchovies, Green -Olives, Red Onions, Garlic)

    • -
    • the_greek: The Greek Pizza (Kalamata Olives, Feta Cheese, -Tomatoes, Garlic, Beef Chuck Roast, Red Onions)

    • -
    -

    Chicken Pizzas:

      -
    • thai_ckn: The Thai Chicken Pizza (Chicken, Pineapple, Tomatoes, -Red Peppers, Thai Sweet Chilli Sauce)

    • -
    • bbq_ckn: The Barbecue Chicken Pizza (Barbecued Chicken, Red -Peppers, Green Peppers, Tomatoes, Red Onions, Barbecue Sauce)

    • -
    • southw_ckn: The Southwest Chicken Pizza (Chicken, Tomatoes, Red -Peppers, Red Onions, Jalapeno Peppers, Corn, Cilantro, Chipotle Sauce)

    • -
    • cali_ckn: The California Chicken Pizza (Chicken, Artichoke, -Spinach, Garlic, JalapeƱo Peppers, Fontina Cheese, Gouda Cheese)

    • -
    • ckn_pesto: The Chicken Pesto Pizza (Chicken, Tomatoes, Red -Peppers, Spinach, Garlic, Pesto Sauce)

    • -
    • ckn_alfredo: The Chicken Alfredo Pizza (Chicken, Red Onions, -Red Peppers, Mushrooms, Asiago Cheese, Alfredo Sauce)

    • -
    -

    Supreme Pizzas:

      -
    • brie_carre: The Brie Carre Pizza (Brie Carre Cheese, Prosciutto, - Caramelized Onions, Pears, Thyme, Garlic)

    • -
    • calabrese: The Calabrese Pizza (ā€˜Nduja Salami, Pancetta, -Tomatoes, Red Onions, Friggitello Peppers, Garlic)

    • -
    • soppressata: The Soppressata Pizza (Soppressata Salami, Fontina -Cheese, Mozzarella Cheese, Mushrooms, Garlic)

    • -
    • sicilian: The Sicilian Pizza (Coarse Sicilian Salami, Tomatoes, -Green Olives, Luganega Sausage, Onions, Garlic)

    • -
    • ital_supr: The Italian Supreme Pizza (Calabrese Salami, -Capocollo, Tomatoes, Red Onions, Green Olives, Garlic)

    • -
    • peppr_salami: The Pepper Salami Pizza (Genoa Salami, Capocollo, -Pepperoni, Tomatoes, Asiago Cheese, Garlic)

    • -
    • prsc_argla: The Prosciutto and Arugula Pizza (Prosciutto di San -Daniele, Arugula, Mozzarella Cheese)

    • -
    • spinach_supr: The Spinach Supreme Pizza (Spinach, Red Onions, -Pepperoni, Tomatoes, Artichokes, Kalamata Olives, Garlic, Asiago Cheese)

    • -
    • spicy_ital: The Spicy Italian Pizza (Capocollo, Tomatoes, Goat -Cheese, Artichokes, Peperoncini verdi, Garlic)

    • -
    -

    Vegetable Pizzas

      -
    • mexicana: The Mexicana Pizza (Tomatoes, Red Peppers, Jalapeno -Peppers, Red Onions, Cilantro, Corn, Chipotle Sauce, Garlic)

    • -
    • four_cheese: The Four Cheese Pizza (Ricotta Cheese, Gorgonzola -Piccante Cheese, Mozzarella Cheese, Parmigiano Reggiano Cheese, Garlic)

    • -
    • five_cheese: The Five Cheese Pizza (Mozzarella Cheese, Provolone -Cheese, Smoked Gouda Cheese, Romano Cheese, Blue Cheese, Garlic)

    • -
    • spin_pesto: The Spinach Pesto Pizza (Spinach, Artichokes, -Tomatoes, Sun-dried Tomatoes, Garlic, Pesto Sauce)

    • -
    • veggie_veg: The Vegetables + Vegetables Pizza (Mushrooms, -Tomatoes, Red Peppers, Green Peppers, Red Onions, Zucchini, Spinach, Garlic)

    • -
    • green_garden: The Green Garden Pizza (Spinach, Mushrooms, -Tomatoes, Green Olives, Feta Cheese)

    • -
    • mediterraneo: The Mediterranean Pizza (Spinach, Artichokes, -Kalamata Olives, Sun-dried Tomatoes, Feta Cheese, Plum Tomatoes, Red Onions)

    • -
    • spinach_fet: The Spinach and Feta Pizza (Spinach, Mushrooms, -Red Onions, Feta Cheese, Garlic)

    • -
    • ital_veggie: The Italian Vegetables Pizza (Eggplant, Artichokes, -Tomatoes, Zucchini, Red Peppers, Garlic, Pesto Sauce)

    • -
    - - -

    Examples

    -
    # Here is a glimpse at the data -# available in `pizzaplace` -dplyr::glimpse(pizzaplace)
    #> Observations: 49,574 -#> Variables: 7 -#> $ id <chr> "2015-000001", "2015-000002", "2015-000002", "2015-000002", "20ā€¦ -#> $ date <chr> "2015-01-01", "2015-01-01", "2015-01-01", "2015-01-01", "2015-0ā€¦ -#> $ time <chr> "11:38:36", "11:57:40", "11:57:40", "11:57:40", "11:57:40", "11ā€¦ -#> $ name <chr> "hawaiian", "classic_dlx", "mexicana", "thai_ckn", "five_cheeseā€¦ -#> $ size <chr> "M", "M", "M", "L", "L", "L", "L", "M", "M", "M", "S", "S", "S"ā€¦ -#> $ type <chr> "classic", "classic", "veggie", "chicken", "veggie", "supreme",ā€¦ -#> $ price <dbl> 13.25, 16.00, 16.00, 20.75, 18.50, 20.75, 20.75, 16.50, 16.50, ā€¦
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/print.gt_tbl.html b/docs/reference/print.gt_tbl.html deleted file mode 100644 index daa3a183eb..0000000000 --- a/docs/reference/print.gt_tbl.html +++ /dev/null @@ -1,180 +0,0 @@ - - - - - - - - -Print the table ā€” print.gt_tbl ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    This facilitates printing of the HTML table to the R console.

    - -
    - -
    # S3 method for gt_tbl
    -print(x, ..., view = interactive())
    - -

    Arguments

    - - - - - - -
    x

    an object of class gt_tbl.

    - - -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/px.html b/docs/reference/px.html deleted file mode 100644 index 10f6bfb9c5..0000000000 --- a/docs/reference/px.html +++ /dev/null @@ -1,190 +0,0 @@ - - - - - - - - -Helper for providing a numeric value as pixels value ā€” px ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Helper for providing a numeric value as pixels value

    - -
    - -
    px(x)
    - -

    Arguments

    - - - - - - -
    x

    the numeric value to format as a string (e.g., "12px") for -some tab_options() arguments that can take values as units of -pixels (e.g., table.font.size).

    - -

    See also

    - -

    Other helper functions: cells_styles, - escape_latex, - gt_latex_dependencies, html, - md, pct

    - - -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/reexports.html b/docs/reference/reexports.html deleted file mode 100644 index 5ea59efa9d..0000000000 --- a/docs/reference/reexports.html +++ /dev/null @@ -1,180 +0,0 @@ - - - - - - - - -Objects exported from other packages ā€” reexports ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    These objects are imported from other packages. Follow the links -below to see their documentation.

    -
    -
    dplyr

    vars

    - -
    tidyselect

    starts_with, ends_with, contains, matches, one_of, everything

    -
    - -
    - - - -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/render_gt.html b/docs/reference/render_gt.html deleted file mode 100644 index 40fd42ceee..0000000000 --- a/docs/reference/render_gt.html +++ /dev/null @@ -1,202 +0,0 @@ - - - - - - - - -A <span class="pkg">gt</span> display table render function for use in Shiny ā€” render_gt ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -gt display table render function for use in Shiny ā€” render_gt" /> - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    A gt display table render function for use in Shiny

    - -
    - -
    render_gt(expr, env = parent.frame(), quoted = FALSE,
    -  outputArgs = list())
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - -
    expr

    an expression that creates a gt table object.

    env

    the environment in which to evaluate the expr.

    quoted

    is expr a quoted expression (with quote())? This is -useful if you want to save an expression in a variable.

    outputArgs

    A list of arguments to be passed through to the implicit -call to gt_output() when render_gt is used in an -interactive R Markdown document.

    - -

    See also

    - -

    gt_output()

    -

    Other Shiny functions: gt_output

    - - -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/row_group_order.html b/docs/reference/row_group_order.html deleted file mode 100644 index 1ac266079b..0000000000 --- a/docs/reference/row_group_order.html +++ /dev/null @@ -1,232 +0,0 @@ - - - - - - - - -Modify the ordering of any row groups ā€” row_group_order ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    We can modify the display order of any row groups in a gt object with -the row_group_order() function. The groups argument can either -take a vector of row group names or a numeric vector of row group indices; -whichever is provided, the row groups will adhere to this revised ordering. -It isn't necessary to provide all row group names in groups, rather, -what is provided will assume the specified ordering at the top of the table -and the remaining row groups will follow in their original ordering.

    - -
    - -
    row_group_order(data, groups)
    - -

    Arguments

    - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    groups

    a vector of row group names, or, a numeric vector of indices -corresponding to the new ordering. Either vector must correspond to -assigned group names or the index positions. Also, either type of vector is -not required to have all of the row group names or available index -positions within it; any omitted values will be added to the end while -preserving the original ordering.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Figures

    - - -

    - - -

    Examples

    -
    # Use `exibble` to create a gt table -# with a stub and with row groups; -# modify the order of the row groups -# with `row_group_order()`, specifying -# the new ordering in `groups` -tab_1 <- - exibble %>% - dplyr::select(char, currency, row, group) %>% - gt( - rowname_col = "row", - groupname_col = "group" - ) %>% - row_group_order( - groups = c("grp_b", "grp_a") - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/sp500.html b/docs/reference/sp500.html deleted file mode 100644 index d7e399b76c..0000000000 --- a/docs/reference/sp500.html +++ /dev/null @@ -1,205 +0,0 @@ - - - - - - - - -Daily S&P 500 Index data from 1950 to 2015 ā€” sp500 ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    This dataset provides daily price indicators for the S&P 500 index from the -beginning of 1950 to the end of 2015. The index includes 500 leading -companies and captures about 80% coverage of available market capitalization.

    - -
    - -
    sp500
    - -

    Format

    - -

    A tibble with 16607 rows and 7 variables:

    -
    date

    The date expressed as Date values

    -
    open, high, low, close

    The day's opening, high, low, and closing - prices in USD; the close price is adjusted for splits

    -
    volume

    the number of trades for the given date

    -
    adj_close

    The close price adjusted for both dividends and splits

    -
    - -

    Source

    - -

    Data collected from https://finance.yahoo.com/quote/%5EGSPC/history/.

    - - -

    Examples

    -
    # Here is a glimpse at the data -# available in `sp500` -dplyr::glimpse(sp500)
    #> Observations: 16,607 -#> Variables: 7 -#> $ date <date> 2015-12-31, 2015-12-30, 2015-12-29, 2015-12-28, 2015-12-24ā€¦ -#> $ open <dbl> 2060.59, 2077.34, 2060.54, 2057.77, 2063.52, 2042.20, 2023.ā€¦ -#> $ high <dbl> 2062.54, 2077.34, 2081.56, 2057.77, 2067.36, 2064.73, 2042.ā€¦ -#> $ low <dbl> 2043.62, 2061.97, 2060.54, 2044.20, 2058.73, 2042.20, 2020.ā€¦ -#> $ close <dbl> 2043.94, 2063.36, 2078.36, 2056.50, 2060.99, 2064.29, 2038.ā€¦ -#> $ volume <dbl> 2655330000, 2367430000, 2542000000, 2492510000, 1411860000,ā€¦ -#> $ adj_close <dbl> 2043.94, 2063.36, 2078.36, 2056.50, 2060.99, 2064.29, 2038.ā€¦
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/summary_rows.html b/docs/reference/summary_rows.html deleted file mode 100644 index 4935ca938d..0000000000 --- a/docs/reference/summary_rows.html +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - - - -Add summary rows using aggregation functions ā€” summary_rows ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Add summary rows to one or more row groups by using the input data already -provided in the gt() function alongside any suitable -aggregation functions. Should we need to obtain the summary data for external -purposes, the extract_summary() can be used with a -gt_tbl object where summary rows were added via summary_rows().

    - -
    - -
    summary_rows(data, groups = NULL, columns = NULL, fns,
    -  missing_text = "---", formatter = fmt_number, ...)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() function.

    groups

    the row groups labels that identify which summary rows will be -added.

    columns

    the columns for which the summaries should be calculated. If -nothing is provided, then the supplied aggregation functions will be -applied to all columns.

    fns

    functions used for aggregations. This can include base functions -like mean, min, max, median, sd, or -sum or any other user-defined aggregation function. The function(s) -should be supplied within a list(). Within that list, we can specify -the functions by use of function names (e.g., "sum"), the functions -themselves (e.g., sum), or one-sided R formulas by prefacing with a -~ where . serves as the data to be summarized (e.g., -sum(., na.rm = TRUE)). By using named arguments, the names will -serve as row labels for the corresponding summary rows (otherwise the -labels will be derived from the function names).

    missing_text

    the text to be used in place of NA values in -summary cells with no data outputs.

    formatter

    a formatter function name. These can be any of the -fmt_*()functions available in the package (e.g., -fmt_number(), link{fmt_percent}(), etc.), or a custom -function using fmt(). The default function is -fmt_number() and its options can be accessed through -....

    ...

    values passed to the formatter function, where the provided -values are to be in the form of named vectors. For example, when using the -default formatter function, fmt_number(), options such -as decimals, use_seps, and locale can be used.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Figures

    - - -

    - - -

    Examples

    -
    # Use `sp500` to create a gt table with -# row groups; create summary rows (`min`, -# `max`, `avg`) by row group, where each -# each row group is a week number -tab_1 <- - sp500 %>% - dplyr::filter( - date >= "2015-01-05" & - date <="2015-01-16" - ) %>% - dplyr::arrange(date) %>% - dplyr::mutate( - week = paste0( - "W", strftime(date, format = "%V")) - ) %>% - dplyr::select(-adj_close, -volume) %>% - gt( - rowname_col = "date", - groupname_col = "week" - ) %>% - summary_rows( - groups = TRUE, - columns = vars(open, high, low, close), - fns = list( - min = ~min(.), - max = ~max(.), - avg = ~mean(.)), - formatter = fmt_number, - use_seps = FALSE - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/sza.html b/docs/reference/sza.html deleted file mode 100644 index 07483c4fb5..0000000000 --- a/docs/reference/sza.html +++ /dev/null @@ -1,226 +0,0 @@ - - - - - - - - -Twice hourly solar zenith angles by month & latitude ā€” sza ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    This dataset contains solar zenith angles (in degrees, with the range of -0-90) every half hour from 04:00 to 12:00, true solar time. This set of -values is calculated on the first of every month for 4 different northern -hemisphere latitudes. For determination of afternoon values, the presented -tabulated values are symmetric about noon.

    - -
    - -
    sza
    - -

    Format

    - -

    A tibble with 816 rows and 4 variables:

    -
    latitude

    The latitude in decimal degrees for the observations

    -
    month

    The measurement month; all calculations where conducted - for the first day of each month

    -
    tst

    The true solar time at the given latitude and date - (first of month) for which the solar zenith angle is calculated

    -
    sza

    The solar zenith angle in degrees, where NAs - indicate that sunrise hadn't yet occurred by the tst value

    -
    - -

    Source

    - -

    Calculated Actinic Fluxes (290 - 700 nm) for Air Pollution -Photochemistry Applications (Peterson, 1976), available at: -https://nepis.epa.gov/Exe/ZyPURL.cgi?Dockey=9100JA26.txt.

    - -

    Details

    - -

    The solar zenith angle (SZA) is one measure that helps to describe the sun's -path across the sky. It's defined as the angle of the sun relative to a line -perpendicular to the earth's surface. It is useful to calculate the SZA in -relation to the true solar time. True solar time relates to the position of -the sun with respect to the observer, which is different depending on the -exact longitude. For example, two hours before the sun crosses the meridian -(the highest point it would reach that day) corresponds to a true solar time -of 10 a.m. The SZA has a strong dependence on the observer's latitude. For -example, at a latitude of 50 degrees N at the start of January, the noontime -SZA is 73.0 but a different observer at 20 degrees N would measure the -noontime SZA to be 43.0 degrees.

    - - -

    Examples

    -
    # Here is a glimpse at the data -# available in `sza` -dplyr::glimpse(sza)
    #> Observations: 816 -#> Variables: 4 -#> $ latitude <dbl> 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, ā€¦ -#> $ month <fct> jan, jan, jan, jan, jan, jan, jan, jan, jan, jan, jan, jan, ā€¦ -#> $ tst <chr> "0400", "0430", "0500", "0530", "0600", "0630", "0700", "073ā€¦ -#> $ sza <dbl> NA, NA, NA, NA, NA, NA, 84.9, 78.7, 72.7, 66.1, 61.5, 56.5, ā€¦
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/tab_footnote.html b/docs/reference/tab_footnote.html deleted file mode 100644 index b7c6be29f2..0000000000 --- a/docs/reference/tab_footnote.html +++ /dev/null @@ -1,284 +0,0 @@ - - - - - - - - -Add a table footnote ā€” tab_footnote ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    The tab_footnote() function can make it a painless process to add a -footnote to a gt table. There are two components to a footnote: (1) a -glyph that is attached to the targeted cell text, and (2) the footnote text -(that starts with the corresponding glyph) that is placed in the table's -footer area. Each call of tab_footnote() will add a different note, -and one or more cells can be targeted via the location helper functions -(e.g., cells_data(), cells_column_labels(), -etc.).

    - -
    - -
    tab_footnote(data, footnote, locations)
    - -

    Arguments

    - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    footnote

    the text to be used in the footnote. We can optionally use -the md() and html() functions to style the text -as Markdown or to retain HTML elements in the footnote text.

    locations

    the cell or set of cells to be associated with the footnote. -Supplying any of the cells_*() helper functions is a useful way to -target the location cells that are associated with the footnote text. These -helper functions are: cells_title(), -cells_column_labels(), cells_group(), -cells_stub(), cells_data(), and -cells_summary(). Please see the help article -location_cells for more information on how these helper functions -can be used. Additionally, we can enclose several cells_*() calls -within a list() if we wish to link the footnote text to different -types of locations (e.g., cell data values, stub group headings, the table -title, etc.).

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Details

    - -

    The formatting of the footnotes can be controlled through the use of various -parameters in the tab_options() function:

    -
      -
    • footnote.sep: allows for a choice of the separator between -consecutive footnotes in the table footer. By default, this is set to a -linebreak.

    • -
    • footnote.glyph: the set of sequential characters or numbers -used to identify the footnotes.

    • -
    • footnote.font.size: the size of the font used in the footnote -section.

    • -
    • footnote.padding: the amount of padding to apply between the -footnote and source note sections in the table footer.

    • -
    - -

    Figures

    - - -

    - -

    See also

    - -

    Other table-part creation/modification functions: gt_preview, - gt, tab_header, - tab_options, tab_row_group, - tab_source_note, tab_spanner, - tab_stubhead_label, tab_style

    - - -

    Examples

    -
    # Use `sza` to create a gt table; color -# the `sza` column using the `data_color()` -# function, then, add a footnote to the -# `sza` column label explaining what the -# color scale signifies -tab_1 <- - sza %>% - dplyr::filter( - latitude == 20 & - month == "jan" & - !is.na(sza) - ) %>% - dplyr::select(-latitude, -month) %>% - gt() %>% - data_color( - columns = vars(sza), - colors = scales::col_numeric( - palette = c("white", "yellow", "navyblue"), - domain = c(0, 90)) - ) %>% - tab_footnote( - footnote = "Color indicates height of sun.", - locations = cells_column_labels( - columns = vars(sza)) - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/tab_header.html b/docs/reference/tab_header.html deleted file mode 100644 index d2fb163a35..0000000000 --- a/docs/reference/tab_header.html +++ /dev/null @@ -1,233 +0,0 @@ - - - - - - - - -Add a table header ā€” tab_header ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    We can add a table header to the gt table with a title and even a -subtitle. A table header is an optional table part that is positioned above -the column labels. We have the flexibility to use Markdown formatting for the -header's title and subtitle. Furthermore, if the table is intended for HTML -output, we can use HTML in either of the title or subtitle.

    - -
    - -
    tab_header(data, title, subtitle = NULL)
    - -

    Arguments

    - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    title, subtitle

    text to be used in the table title and, optionally, for -the table subtitle. We can elect to use the md() and -html() helper functions to style the text as Markdown or to -retain HTML elements in the text.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Figures

    - - -

    - -

    See also

    - -

    Other table-part creation/modification functions: gt_preview, - gt, tab_footnote, - tab_options, tab_row_group, - tab_source_note, tab_spanner, - tab_stubhead_label, tab_style

    - - -

    Examples

    -
    # Use `gtcars` to create a gt table; -# add a header part to contain a title -# and subtitle -tab_1 <- - gtcars %>% - dplyr::select(mfr, model, msrp) %>% - dplyr::slice(1:5) %>% - gt() %>% - tab_header( - title = md("Data listing from **gtcars**"), - subtitle = md("`gtcars` is an R dataset") - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/tab_options.html b/docs/reference/tab_options.html deleted file mode 100644 index bcc4fb5728..0000000000 --- a/docs/reference/tab_options.html +++ /dev/null @@ -1,413 +0,0 @@ - - - - - - - - -Modify the table output options ā€” tab_options ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Modify the options available in a table. These options are named by the -components, the subcomponents, and the element that can adjusted.

    - -
    - -
    tab_options(data, table.width = NULL, table.font.size = NULL,
    -  table.background.color = NULL, table.border.top.style = NULL,
    -  table.border.top.width = NULL, table.border.top.color = NULL,
    -  heading.background.color = NULL, heading.title.font.size = NULL,
    -  heading.subtitle.font.size = NULL,
    -  heading.border.bottom.style = NULL,
    -  heading.border.bottom.width = NULL,
    -  heading.border.bottom.color = NULL,
    -  column_labels.background.color = NULL,
    -  column_labels.font.size = NULL, column_labels.font.weight = NULL,
    -  stub_group.background.color = NULL, stub_group.font.size = NULL,
    -  stub_group.font.weight = NULL, stub_group.border.top.style = NULL,
    -  stub_group.border.top.width = NULL,
    -  stub_group.border.top.color = NULL,
    -  stub_group.border.bottom.style = NULL,
    -  stub_group.border.bottom.width = NULL,
    -  stub_group.border.bottom.color = NULL, field.border.top.style = NULL,
    -  field.border.top.width = NULL, field.border.top.color = NULL,
    -  field.border.bottom.style = NULL, field.border.bottom.width = NULL,
    -  field.border.bottom.color = NULL, row.padding = NULL,
    -  summary_row.background.color = NULL, summary_row.padding = NULL,
    -  summary_row.text_transform = NULL, footnote.sep = NULL,
    -  footnote.glyph = NULL, footnote.font.size = NULL,
    -  footnote.padding = NULL, sourcenote.font.size = NULL,
    -  sourcenote.padding = NULL, row.striping.include_stub = NULL,
    -  row.striping.include_field = NULL)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    table.width

    the width of the table. Can be specified as a -single-length character with units of pixels or as a percentage. If -provided as a single-length numeric vector, it is assumed that the value is -given in units of pixels. The px() and pct() -helper functions can also be used to pass in numeric values and obtain -values as pixel or percent units.

    table.font.size, heading.title.font.size, heading.subtitle.font.size, column_labels.font.size, stub_group.font.size, footnote.font.size, sourcenote.font.size

    font sizes for the parent text element table and the following child -elements: heading.title, heading.subtitle, columns, -stub_group, footnote, and sourcenote. Can be specified -as a single-length character vector with units of pixels -(e.g., 12px) or as a percentage (e.g., 80%). If provided as a -single-length numeric vector, it is assumed that the value is given in -units of pixels. The px() and pct() helper -functions can also be used to pass in numeric values and obtain values as -pixel or percent units.

    table.background.color, heading.background.color, column_labels.background.color, stub_group.background.color, summary_row.background.color

    background colors for the parent element table and the following -child elements: heading, columns, stub_group, -summary_row, and field. A color name or a hexadecimal color -code should be provided.

    table.border.top.style, table.border.top.width, table.border.top.color

    the style, width, and color of the table's top border.

    heading.border.bottom.style, heading.border.bottom.width, heading.border.bottom.color

    the style, width, and color of the heading's bottom border.

    column_labels.font.weight, stub_group.font.weight

    the font weight of the -columns and stub_group text element.

    stub_group.border.top.style, stub_group.border.top.width, stub_group.border.top.color

    the style, width, and color of the stub heading's top border.

    stub_group.border.bottom.style, stub_group.border.bottom.width, stub_group.border.bottom.color

    the style, width, and color of the stub heading's bottom border.

    field.border.top.style, field.border.top.width, field.border.top.color

    the style, width, and color of the field's top border.

    field.border.bottom.style, field.border.bottom.width, field.border.bottom.color

    the style, width, and color of the field's bottom border.

    row.padding, summary_row.padding

    the amount of padding in each row and -in each summary row.

    summary_row.text_transform

    an option to apply text transformations to -the label text in each summary row.

    footnote.sep

    the separating characters between adjacent footnotes in -the footnotes section. The default value produces a linebreak.

    footnote.glyph

    the set of sequential figures or characters used to -identify the footnotes. We can either supply the keyword "numbers" -(the default, indicating that we want numeric glyphs), the keywords -"letters" or "LETTERS" (indicating that we want letters as -glyphs, either lowercase or uppercase), or, a vector of character values -representing the series of glyphs. A series of glyphs is recycled when its -usage goes beyond the length of the set. At each cycle, the glyphs are -simply combined (e.g., * -> ** -> ***).

    footnote.padding, sourcenote.padding

    the amount of padding to apply to -the footnote and source note sections.

    row.striping.include_stub

    an option for whether to include the stub -when striping rows.

    row.striping.include_field

    an option for whether to include the field -when striping rows.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Figures

    - - -

    -

    -

    -

    -

    -

    - -

    See also

    - -

    Other table-part creation/modification functions: gt_preview, - gt, tab_footnote, - tab_header, tab_row_group, - tab_source_note, tab_spanner, - tab_stubhead_label, tab_style

    - - -

    Examples

    -
    # Use `exibble` to create a gt table with -# all the main parts added; we can use this -# going forward to demo some `tab_options()` -tab_1 <- - exibble %>% - dplyr::select( - -c(fctr, date, time, datetime) - ) %>% - gt( - rowname_col = "row", - groupname_col = "group" - ) %>% - tab_header( - title = md("Data listing from **exibble**"), - subtitle = md("`exibble` is an R dataset") - ) %>% - fmt_number(columns = vars(num)) %>% - fmt_currency(columns = vars(currency)) %>% - tab_footnote( - footnote = "Using commas for separators.", - locations = cells_data( - columns = vars(num), - rows = num > 1000) - ) %>% - tab_footnote( - footnote = "Using commas for separators.", - locations = cells_data( - columns = vars(currency), - rows = currency > 1000) - ) %>% - tab_footnote( - footnote = "Alphabetical fruit.", - locations = cells_column_labels( - columns = vars(char)) - ) - -# Modify the table width to 100% (which -# spans the entire content width area) -tab_2 <- - tab_1 %>% - tab_options( - table.width = pct(100) - ) - -# Modify the table's background color -# to be "lightcyan" -tab_3 <- - tab_1 %>% - tab_options( - table.background.color = "lightcyan" - ) - -# Use letters as the glyphs for footnote -# references; also, separate footnotes in -# the footer by spaces instead of newlines -tab_4 <- - tab_1 %>% - tab_options( - footnote.sep = " ", - footnote.glyph = letters - ) - -# Change the padding of data rows to 5px -tab_5 <- - tab_1 %>% - tab_options( - row.padding = px(5) - ) - -# Reduce the size of the title and the -# subtitle text -tab_6 <- - tab_1 %>% - tab_options( - heading.title.font.size = "small", - heading.subtitle.font.size = "small" - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/tab_row_group.html b/docs/reference/tab_row_group.html deleted file mode 100644 index a04742674f..0000000000 --- a/docs/reference/tab_row_group.html +++ /dev/null @@ -1,268 +0,0 @@ - - - - - - - - -Add a row group ā€” tab_row_group ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Create a row group with a collection of rows. This requires specification of -the rows to be included, either by supplying row labels, row indices, or -through use of a select helper function like starts_with().

    - -
    - -
    tab_row_group(data, group = NULL, rows = NULL, others = NULL)
    - -

    Arguments

    - - - - - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    group

    the name of the row group. This text will also serve as the row -group label.

    rows

    the rows to be made components of the row group. Can either be a -vector of row captions provided c(), a vector of row indices, or a -helper function focused on selections. The select helper functions are: -starts_with(), ends_with(), -contains(), matches(), one_of(), -and everything().

    others

    an option to set a default row group label for any rows not -formally placed in a row group named by group in any call of -tab_row_group(). A separate call to tab_row_group() with only -a value to others is possible and makes explicit that the call is -meant to provide a default row group label. If this is not set and -there are rows that haven't been placed into a row group (where one or -more row groups already exist), those rows will be automatically placed into -a row group without a label.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Figures

    - - -

    -

    - -

    See also

    - -

    Other table-part creation/modification functions: gt_preview, - gt, tab_footnote, - tab_header, tab_options, - tab_source_note, tab_spanner, - tab_stubhead_label, tab_style

    - - -

    Examples

    -
    # Use `gtcars` to create a gt table and -# add two row groups with the labels: -# `numbered` and `NA` (a group without -# a title, or, the rest) -tab_1 <- - gtcars %>% - dplyr::select(model, year, hp, trq) %>% - dplyr::slice(1:8) %>% - gt(rowname_col = "model") %>% - tab_row_group( - group = "numbered", - rows = matches("^[0-9]") - ) - -# Use `gtcars` to create a gt table; -# add two row groups with the labels -# `powerful` and `super powerful`: the -# distinction being `hp` lesser or -# greater than `600` -tab_2 <- - gtcars %>% - dplyr::select(model, year, hp, trq) %>% - dplyr::slice(1:8) %>% - gt(rowname_col = "model") %>% - tab_row_group( - group = "powerful", - rows = hp <= 600 - ) %>% - tab_row_group( - group = "super powerful", - rows = hp > 600 - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/tab_source_note.html b/docs/reference/tab_source_note.html deleted file mode 100644 index 5340de8256..0000000000 --- a/docs/reference/tab_source_note.html +++ /dev/null @@ -1,233 +0,0 @@ - - - - - - - - -Add a source note citation ā€” tab_source_note ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Add a source note to the footer part of the gt table. A source note is -useful for citing the data included in the table. Several can be added to the -footer, simply use multiple calls of tab_source_note() and they will -be inserted in the order provided. We can use Markdown formatting for the -note, or, if the table is intended for HTML output, we can include HTML -formatting.

    - -
    - -
    tab_source_note(data, source_note)
    - -

    Arguments

    - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    source_note

    text to be used in the source note. We can optionally use -the md() and html() functions to style the text -as Markdown or to retain HTML elements in the text.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Figures

    - - -

    - -

    See also

    - -

    Other table-part creation/modification functions: gt_preview, - gt, tab_footnote, - tab_header, tab_options, - tab_row_group, tab_spanner, - tab_stubhead_label, tab_style

    - - -

    Examples

    -
    # Use `gtcars` to create a gt table; -# add a source note to the table -# footer that cites the data source -tab_1 <- - gtcars %>% - dplyr::select(mfr, model, msrp) %>% - dplyr::slice(1:5) %>% - gt() %>% - tab_source_note( - source_note = "From edmunds.com" - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/tab_spanner.html b/docs/reference/tab_spanner.html deleted file mode 100644 index b1765b1772..0000000000 --- a/docs/reference/tab_spanner.html +++ /dev/null @@ -1,237 +0,0 @@ - - - - - - - - -Add a spanner column label ā€” tab_spanner ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Set a spanner column label by mapping it to columns already in the table. -This label is placed above one or more column labels, spanning the width of -those columns and column labels.

    - -
    - -
    tab_spanner(data, label, columns)
    - -

    Arguments

    - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    label

    the text to use for the spanner column label.

    columns

    the columns to be components of the spanner heading.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Figures

    - - -

    - -

    See also

    - -

    Other table-part creation/modification functions: gt_preview, - gt, tab_footnote, - tab_header, tab_options, - tab_row_group, - tab_source_note, - tab_stubhead_label, tab_style

    - - -

    Examples

    -
    # Use `gtcars` to create a gt table; -# Group several columns related to car -# performance under a spanner column -# with the label `performance` -tab_1 <- - gtcars %>% - dplyr::select( - -mfr, -trim, bdy_style, drivetrain, - -drivetrain, -trsmn, -ctry_origin - ) %>% - dplyr::slice(1:8) %>% - gt(rowname_col = "model") %>% - tab_spanner( - label = "performance", - columns = vars( - hp, hp_rpm, trq, trq_rpm, - mpg_c, mpg_h) - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/tab_stubhead_label.html b/docs/reference/tab_stubhead_label.html deleted file mode 100644 index 7642ae3220..0000000000 --- a/docs/reference/tab_stubhead_label.html +++ /dev/null @@ -1,232 +0,0 @@ - - - - - - - - -Add label text to the stubhead ā€” tab_stubhead_label ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Add a label to the stubhead of a gt table. The stubhead is the lone -element that is positioned left of the column labels, and above the stub. If -a stub does not exist, then there is no stubhead (so no change will be made -when using this function in that case). We have the flexibility to use -Markdown formatting for the stubhead label. Furthermore, if the table is -intended for HTML output, we can use HTML for the stubhead label.

    - -
    - -
    tab_stubhead_label(data, label)
    - -

    Arguments

    - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    label

    the text to be used as the stubhead label We can optionally -use the md() and html() functions to style the -text as Markdown or to retain HTML elements in the text.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Figures

    - - -

    - -

    See also

    - -

    Other table-part creation/modification functions: gt_preview, - gt, tab_footnote, - tab_header, tab_options, - tab_row_group, - tab_source_note, tab_spanner, - tab_style

    - - -

    Examples

    -
    # Use `gtcars` to create a gt table; add -# a stubhead label to describe what is -# in the stub -tab_1 <- - gtcars %>% - dplyr::select(model, year, hp, trq) %>% - dplyr::slice(1:5) %>% - gt(rowname_col = "model") %>% - tab_stubhead_label(label = "car")
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/tab_style.html b/docs/reference/tab_style.html deleted file mode 100644 index e25d245593..0000000000 --- a/docs/reference/tab_style.html +++ /dev/null @@ -1,327 +0,0 @@ - - - - - - - - -Add custom styles to one or more cells ā€” tab_style ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    With the tab_style() function we can target specific cells and apply -styles to them. This is best done in conjunction with the -cells_styles() helper function. At present this function is -focused on the application of styles for HTML output only (as such, other -output formats will ignore all tab_style() calls). With the help of -cells_styles(), we can set the following styles:

      -
    • the background color of the cell (bkgd_color)

    • -
    • the cell's text color (text_color), font (text_font), or -size (text_size)

    • -
    • the text style (text_style), enabling the use of italics or -oblique text.

    • -
    • text decoration (text_decorate): use overlines, line-throughs, -or underlines

    • -
    • text transformations (text_transform) that result in lowercased, -uppercased, or capitalized text

    • -
    • the text weight (text_weight), allowing the use of thin to -bold text (the degree of choice is greater with variable fonts)

    • -
    • the alignment of text (text_align)

    • -
    • a stretching property for text that condenses or expands text -(text_stretch)

    • -
    • the text indentation (text_indent)

    • -
    - -
    - -
    tab_style(data, style, locations)
    - -

    Arguments

    - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    style

    a vector of styles to use. The cells_styles() -helper function can be used here to more easily generate valid styles.

    locations

    the cell or set of cells to be associated with the style -Supplying any of the cells_*() helper functions is a useful way to -target the location cells that are associated with the style application. -These helper functions are: cells_title(), -cells_column_labels(), cells_group(), -cells_stub(), cells_data(), and -cells_summary(). Please see the help article -location_cells for more information on how these helper functions -can be used. Additionally, we can enclose several cells_*() calls -within a list() if we wish to apply styles to different types of -locations (e.g., cell data values, stub group headings, the table title, -etc.).

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Figures

    - - -

    -

    - -

    See also

    - -

    cells_styles() as a helper for defining custom styles - and cells_data() as a useful helper function for targeting - one or more data cells to be styled.

    -

    Other table-part creation/modification functions: gt_preview, - gt, tab_footnote, - tab_header, tab_options, - tab_row_group, - tab_source_note, tab_spanner, - tab_stubhead_label

    - - -

    Examples

    -
    # Use `exibble` to create a gt table; -# add styles that are to be applied -# to data cells that satisfy a -# condition (using `tab_style()`) -tab_1 <- - exibble %>% - dplyr::select(num, currency) %>% - gt() %>% - fmt_number( - columns = vars(num, currency), - decimals = 1 - ) %>% - tab_style( - style = cells_styles( - bkgd_color = "lightcyan", - text_weight = "bold"), - locations = cells_data( - columns = vars(num), - rows = num >= 5000) - ) %>% - tab_style( - style = cells_styles( - bkgd_color = "#F9E3D6", - text_style = "italic"), - locations = cells_data( - columns = vars(currency), - rows = currency < 100) - ) - -# Use `sp500` to create a gt table; -# color entire rows of cells based -# on values in a particular column -tab_2 <- - sp500 %>% - dplyr::filter( - date >= "2015-12-01" & - date <= "2015-12-15" - ) %>% - dplyr::select(-c(adj_close, volume)) %>% - dplyr::mutate(date = as.character(date)) %>% - gt() %>% - tab_style( - style = cells_styles( - bkgd_color = "lightgreen"), - locations = cells_data( - rows = close > open) - ) %>% - tab_style( - style = cells_styles( - bkgd_color = "crimson", - text_color = "white"), - locations = cells_data( - rows = open > close) - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/test_image.html b/docs/reference/test_image.html deleted file mode 100644 index 6108e0ca70..0000000000 --- a/docs/reference/test_image.html +++ /dev/null @@ -1,195 +0,0 @@ - - - - - - - - -Generate a path to a test image ā€” test_image ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Two test images are available within the gt package. Both contain the -same imagery (sized at 200px by 200px) but one is a PNG file while the other -is an SVG file. This function is most useful when paired with -local_image() since we test various sizes of the test image -within that function.

    - -
    - -
    test_image(type = c("png", "svg"))
    - -

    Arguments

    - - - - - - -
    type

    the type of the image, which can either be png (the -default) or svg.

    - -

    See also

    - -

    Other image addition functions: ggplot_image, - local_image, web_image

    - - -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/text_transform.html b/docs/reference/text_transform.html deleted file mode 100644 index b3da6fc5e4..0000000000 --- a/docs/reference/text_transform.html +++ /dev/null @@ -1,263 +0,0 @@ - - - - - - - - -Perform targeted text transformation with a function ā€” text_transform ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    Perform targeted text transformation with a function

    - -
    - -
    text_transform(data, locations, fn)
    - -

    Arguments

    - - - - - - - - - - - - - - -
    data

    a table object that is created using the gt() -function.

    locations

    the cell or set of cells to be associated with the text -transformation. Supplying any of the cells_*() helper functions is a -useful way to target the location cells that are associated with the -footnote text. These helper functions are: cells_title(), -cells_column_labels(), cells_group(), -cells_stub(), cells_data(), and -cells_summary(). Please see the help article -location_cells for more information on how these helper functions -can be used. Additionally, we can enclose several cells_*() calls -within a list() if we wish to link the footnote text to different -types of locations (e.g., cell data values, stub group headings, the table -title, etc.).

    fn

    the function to use for text transformation.

    - -

    Value

    - -

    an object of class gt_tbl.

    - -

    Figures

    - - -

    - -

    See also

    - - - - -

    Examples

    -
    # Use `exibble` to create a gt table; -# transform the formatted text in the -# `num` and `currency` columns using -# a function within `text_transform()`, -# where `x` is a formatted vector of -# column values -tab_1 <- - exibble %>% - dplyr::select(num, char, currency) %>% - dplyr::slice(1:4) %>% - gt() %>% - fmt_number(columns = vars(num)) %>% - fmt_currency(columns = vars(currency)) %>% - text_transform( - locations = cells_data( - columns = vars(num)), - fn = function(x) { - - paste0( - x, " (", - dplyr::case_when( - x > 20 ~ "large", - x <= 20 ~ "small"), - ")") - } - ) %>% - text_transform( - locations = cells_data( - columns = vars(currency)), - fn = function(x) { - - ifelse( - grepl(",", x), - gsub("\\.\\d\\d", "", x), - x) - } - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/reference/web_image.html b/docs/reference/web_image.html deleted file mode 100644 index 4b0f964efc..0000000000 --- a/docs/reference/web_image.html +++ /dev/null @@ -1,297 +0,0 @@ - - - - - - - - -Helper function for adding an image from the web ā€” web_image ā€¢ gt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    - - -
    - -

    We can flexibly add a web image inside of a table with web_image() -function. The function provides a convenient way to generate an HTML fragment -with an image URL. Because this function is currently HTML-based, it is only -useful for HTML table output. To use this function inside of data cells, it -is recommended that the text_transform() function is used. With -that function, we can specify which data cells to target and then include a -web_image() call within the required user-defined function (for the -fn argument). If we want to include an image in other places (e.g., in -the header, within footnote text, etc.) we need to use web_image() -within the html() helper function.

    - -
    - -
    web_image(url, height = 30)
    - -

    Arguments

    - - - - - - - - - - -
    url

    a url that resolves to an image file.

    height

    the absolute height (px) of the image in the table cell.

    - -

    Value

    - -

    a character object with an HTML fragment that can be placed inside of - a cell.

    - -

    Details

    - -

    By itself, the function creates an HTML image tag, so, the call -web_image("http://some.web.site/image.png") evaluates to:

    -

    <img src=\"http://some.web.site/image.png\" style=\"height:30px;\">

    -

    where a height of 30px is a default height chosen to work well within -the heights of most table rows.

    - -

    Figures

    - - -

    -

    - -

    See also

    - -

    Other image addition functions: ggplot_image, - local_image, test_image

    - - -

    Examples

    -
    # Get the PNG-based logo for the R -# Project from an image URL -r_png_url <- - "https://www.r-project.org/logo/Rlogo.png" - -# Create a tibble that contains heights -# of an image in pixels (one column as a -# string, the other as numerical values), -# then, create a gt table; use the -# `text_transform()` function to insert -# the R logo PNG image with the various -# sizes -tab_1 <- - dplyr::tibble( - pixels = px(seq(10, 35, 5)), - image = seq(10, 35, 5) - ) %>% - gt() %>% - text_transform( - locations = cells_data(vars(image)), - fn = function(x) { - web_image( - url = r_png_url, - height = as.numeric(x) - ) - } - ) - -# Get the SVG-based logo for the R -# Project from an image URL -r_svg_url <- - "https://www.r-project.org/logo/Rlogo.svg" - -# Create a tibble that contains heights -# of an image in pixels (one column as a -# string, the other as numerical values), -# then, create a gt table; use the -# `tab_header()` function to insert -# the R logo SVG image once in the title -# and five times in the subtitle -tab_2 <- - dplyr::tibble( - pixels = px(seq(10, 35, 5)), - image = seq(10, 35, 5) - ) %>% - gt() %>% - tab_header( - title = html( - web_image( - url = r_svg_url, - height = px(50) - ) - ), - subtitle = html( - web_image( - url = r_svg_url, - height = px(12) - ) %>% - rep(5) - ) - )
    -
    - -
    - -
    - - -
    -

    Site built with pkgdown 1.3.0.9000.

    -
    -
    -
    - - - - - - diff --git a/docs/sitemap.xml b/docs/sitemap.xml deleted file mode 100644 index 6a46aed22d..0000000000 --- a/docs/sitemap.xml +++ /dev/null @@ -1,225 +0,0 @@ - - - - https://gt.rstudio.com/index.html - - - https://gt.rstudio.com/reference/adjust_luminance.html - - - https://gt.rstudio.com/reference/as_latex.html - - - https://gt.rstudio.com/reference/as_raw_html.html - - - https://gt.rstudio.com/reference/as_rtf.html - - - https://gt.rstudio.com/reference/cells_styles.html - - - https://gt.rstudio.com/reference/cols_align.html - - - https://gt.rstudio.com/reference/cols_hide.html - - - https://gt.rstudio.com/reference/cols_label.html - - - https://gt.rstudio.com/reference/cols_merge.html - - - https://gt.rstudio.com/reference/cols_merge_range.html - - - https://gt.rstudio.com/reference/cols_merge_uncert.html - - - https://gt.rstudio.com/reference/cols_move.html - - - https://gt.rstudio.com/reference/cols_move_to_end.html - - - https://gt.rstudio.com/reference/cols_move_to_start.html - - - https://gt.rstudio.com/reference/cols_split_delim.html - - - https://gt.rstudio.com/reference/countrypops.html - - - https://gt.rstudio.com/reference/data_color.html - - - https://gt.rstudio.com/reference/escape_latex.html - - - https://gt.rstudio.com/reference/exibble.html - - - https://gt.rstudio.com/reference/extract_summary.html - - - https://gt.rstudio.com/reference/fmt.html - - - https://gt.rstudio.com/reference/fmt_currency.html - - - https://gt.rstudio.com/reference/fmt_date.html - - - https://gt.rstudio.com/reference/fmt_datetime.html - - - https://gt.rstudio.com/reference/fmt_missing.html - - - https://gt.rstudio.com/reference/fmt_number.html - - - https://gt.rstudio.com/reference/fmt_passthrough.html - - - https://gt.rstudio.com/reference/fmt_percent.html - - - https://gt.rstudio.com/reference/fmt_scientific.html - - - https://gt.rstudio.com/reference/fmt_time.html - - - https://gt.rstudio.com/reference/ggplot_image.html - - - https://gt.rstudio.com/reference/gt-options.html - - - https://gt.rstudio.com/reference/gt-package.html - - - https://gt.rstudio.com/reference/gt.html - - - https://gt.rstudio.com/reference/gt_latex_dependencies.html - - - https://gt.rstudio.com/reference/gt_output.html - - - https://gt.rstudio.com/reference/gt_preview.html - - - https://gt.rstudio.com/reference/gtcars.html - - - https://gt.rstudio.com/reference/html.html - - - https://gt.rstudio.com/reference/info_currencies.html - - - https://gt.rstudio.com/reference/info_date_style.html - - - https://gt.rstudio.com/reference/info_paletteer.html - - - https://gt.rstudio.com/reference/info_time_style.html - - - https://gt.rstudio.com/reference/knit_print.gt_tbl.html - - - https://gt.rstudio.com/reference/local_image.html - - - https://gt.rstudio.com/reference/location_cells.html - - - https://gt.rstudio.com/reference/md.html - - - https://gt.rstudio.com/reference/pct.html - - - https://gt.rstudio.com/reference/pipe.html - - - https://gt.rstudio.com/reference/pizzaplace.html - - - https://gt.rstudio.com/reference/print.gt_tbl.html - - - https://gt.rstudio.com/reference/px.html - - - https://gt.rstudio.com/reference/reexports.html - - - https://gt.rstudio.com/reference/render_gt.html - - - https://gt.rstudio.com/reference/row_group_order.html - - - https://gt.rstudio.com/reference/sp500.html - - - https://gt.rstudio.com/reference/summary_rows.html - - - https://gt.rstudio.com/reference/sza.html - - - https://gt.rstudio.com/reference/tab_footnote.html - - - https://gt.rstudio.com/reference/tab_header.html - - - https://gt.rstudio.com/reference/tab_options.html - - - https://gt.rstudio.com/reference/tab_row_group.html - - - https://gt.rstudio.com/reference/tab_source_note.html - - - https://gt.rstudio.com/reference/tab_spanner.html - - - https://gt.rstudio.com/reference/tab_stubhead_label.html - - - https://gt.rstudio.com/reference/tab_style.html - - - https://gt.rstudio.com/reference/test_image.html - - - https://gt.rstudio.com/reference/text_transform.html - - - https://gt.rstudio.com/reference/web_image.html - - - https://gt.rstudio.com/articles/case-study-gtcars.html - - - https://gt.rstudio.com/articles/creating-summary-lines.html - - - https://gt.rstudio.com/articles/gt-datasets.html - - - https://gt.rstudio.com/articles/intro-creating-gt-tables.html - - diff --git a/inst/css/gt_colors.scss b/inst/css/gt_colors.scss index 8233ab6780..e6277ebdf2 100644 --- a/inst/css/gt_colors.scss +++ b/inst/css/gt_colors.scss @@ -1,7 +1,7 @@ $heading_background_color: $table_background_color !default; $column_labels_background_color: $table_background_color !default; -$stub_group_background_color: $table_background_color !default; +$row_group_background_color: $table_background_color !default; $summary_row_background_color: $table_background_color !default; $grand_summary_row_background_color: $table_background_color !default; diff --git a/inst/css/gt_styles_default.scss b/inst/css/gt_styles_default.scss index 67ebea677a..5da6844ce8 100644 --- a/inst/css/gt_styles_default.scss +++ b/inst/css/gt_styles_default.scss @@ -67,31 +67,31 @@ .gt_group_heading { padding: 8px; - color: font-color($stub_group_background_color); - background-color: $stub_group_background_color; /* stub_group.background.color */ - font-size: $stub_group_font_size; /* stub_group.font.size */ - font-weight: $stub_group_font_weight; /* stub_group.font.weight */ - border-top-style: $stub_group_border_top_style; /* stub_group.border.top.style */ - border-top-width: $stub_group_border_top_width; /* stub_group.border.top.width */ - border-top-color: $stub_group_border_top_color; /* stub_group.border.top.color */ - border-bottom-style: $stub_group_border_bottom_style; /* stub_group.border.bottom.style */ - border-bottom-width: $stub_group_border_bottom_width; /* stub_group.border.bottom.width */ - border-bottom-color: $stub_group_border_bottom_color; /* stub_group.border.bottom.color */ + color: font-color($row_group_background_color); + background-color: $row_group_background_color; /* row_group.background.color */ + font-size: $row_group_font_size; /* row_group.font.size */ + font-weight: $row_group_font_weight; /* row_group.font.weight */ + border-top-style: $row_group_border_top_style; /* row_group.border.top.style */ + border-top-width: $row_group_border_top_width; /* row_group.border.top.width */ + border-top-color: $row_group_border_top_color; /* row_group.border.top.color */ + border-bottom-style: $row_group_border_bottom_style; /* row_group.border.bottom.style */ + border-bottom-width: $row_group_border_bottom_width; /* row_group.border.bottom.width */ + border-bottom-color: $row_group_border_bottom_color; /* row_group.border.bottom.color */ vertical-align: middle; } .gt_empty_group_heading { padding: 0.5px; - color: font-color($stub_group_background_color); - background-color: $stub_group_background_color; /* stub_group.background.color */ - font-size: $stub_group_font_size; /* stub_group.font.size */ - font-weight: $stub_group_font_weight; /* stub_group.font.weight */ - border-top-style: $stub_group_border_top_style; /* stub_group.border.top.style */ - border-top-width: $stub_group_border_top_width; /* stub_group.border.top.width */ - border-top-color: $stub_group_border_top_color; /* stub_group.border.top.color */ - border-bottom-style: $stub_group_border_bottom_style; /* stub_group.border.bottom.style */ - border-bottom-width: $stub_group_border_bottom_width; /* stub_group.border.bottom.width */ - border-bottom-color: $stub_group_border_bottom_color; /* stub_group.border.bottom.color */ + color: font-color($row_group_background_color); + background-color: $row_group_background_color; /* row_group.background.color */ + font-size: $row_group_font_size; /* row_group.font.size */ + font-weight: $row_group_font_weight; /* row_group.font.weight */ + border-top-style: $row_group_border_top_style; /* row_group.border.top.style */ + border-top-width: $row_group_border_top_width; /* row_group.border.top.width */ + border-top-color: $row_group_border_top_color; /* row_group.border.top.color */ + border-bottom-style: $row_group_border_bottom_style; /* row_group.border.bottom.style */ + border-bottom-width: $row_group_border_bottom_width; /* row_group.border.bottom.width */ + border-bottom-color: $row_group_border_bottom_color; /* row_group.border.bottom.color */ vertical-align: middle; } @@ -147,12 +147,12 @@ } .gt_table_body { - border-top-style: $field_border_top_style; /* field.border.top.style */ - border-top-width: $field_border_top_width; /* field.border.top.width */ - border-top-color: $field_border_top_color; /* field.border.top.color */ - border-bottom-style: $field_border_bottom_style; /* field.border.bottom.style */ - border-bottom-width: $field_border_bottom_width; /* field.border.bottom.width */ - border-bottom-color: $field_border_bottom_color; /* field.border.bottom.color */ + border-top-style: $table_body_border_top_style; /* table_body.border.top.style */ + border-top-width: $table_body_border_top_width; /* table_body.border.top.width */ + border-top-color: $table_body_border_top_color; /* table_body.border.top.color */ + border-bottom-style: $table_body_border_bottom_style; /* table_body.border.bottom.style */ + border-bottom-width: $table_body_border_bottom_width; /* table_body.border.bottom.width */ + border-bottom-color: $table_body_border_bottom_color; /* table_body.border.bottom.color */ } .gt_footnote { diff --git a/man/fmt_scientific.Rd b/man/fmt_scientific.Rd index d4afc55689..458ad5823f 100644 --- a/man/fmt_scientific.Rd +++ b/man/fmt_scientific.Rd @@ -58,9 +58,9 @@ locale ID will override any values provided in \code{sep_mark} and an object of class \code{gt_tbl}. } \description{ -With numeric values in a \pkg{gt} table, we can perform formatting so that -the targeted values are presented in scientific notation. We can exert finer -finer control on the formatting with the following options: +With numeric values in a \pkg{gt} table, we can perform formatting so that the +targeted values are rendered in scientific notation. Furthermore, there is +fine control with the following options: \itemize{ \item decimals: choice of the number of decimal places, option to drop trailing zeros, and a choice of the decimal symbol diff --git a/man/location_cells.Rd b/man/location_cells.Rd index 47134431f9..fec9154807 100644 --- a/man/location_cells.Rd +++ b/man/location_cells.Rd @@ -62,10 +62,10 @@ row groups using the \code{groups} argument. \item \code{cells_stub()}: targets row labels in the table stub using the \code{rows} argument. -\item \code{cells_data()}: targets data cells in the table field using +\item \code{cells_data()}: targets data cells in the table body using intersections of \code{columns} and \code{rows}. -\item \code{cells_summary()}: targets summary cells in the table field using +\item \code{cells_summary()}: targets summary cells in the table body using the \code{groups} argument and intersections of \code{columns} and \code{rows}. } diff --git a/man/pizzaplace.Rd b/man/pizzaplace.Rd index 1570cadaf9..66b1e94ed5 100644 --- a/man/pizzaplace.Rd +++ b/man/pizzaplace.Rd @@ -70,7 +70,7 @@ Peppers, Green Peppers, Tomatoes, Red Onions, Barbecue Sauce) \item \code{southw_ckn}: The Southwest Chicken Pizza (Chicken, Tomatoes, Red Peppers, Red Onions, Jalapeno Peppers, Corn, Cilantro, Chipotle Sauce) \item \code{cali_ckn}: The California Chicken Pizza (Chicken, Artichoke, -Spinach, Garlic, JalapeƱo Peppers, Fontina Cheese, Gouda Cheese) +Spinach, Garlic, Jalapeno Peppers, Fontina Cheese, Gouda Cheese) \item \code{ckn_pesto}: The Chicken Pesto Pizza (Chicken, Tomatoes, Red Peppers, Spinach, Garlic, Pesto Sauce) \item \code{ckn_alfredo}: The Chicken Alfredo Pizza (Chicken, Red Onions, diff --git a/man/tab_options.Rd b/man/tab_options.Rd index 92ce616e9b..62d054c691 100644 --- a/man/tab_options.Rd +++ b/man/tab_options.Rd @@ -14,16 +14,18 @@ tab_options(data, table.width = NULL, table.font.size = NULL, heading.border.bottom.color = NULL, column_labels.background.color = NULL, column_labels.font.size = NULL, column_labels.font.weight = NULL, - stub_group.background.color = NULL, stub_group.font.size = NULL, - stub_group.font.weight = NULL, stub_group.border.top.style = NULL, - stub_group.border.top.width = NULL, - stub_group.border.top.color = NULL, - stub_group.border.bottom.style = NULL, - stub_group.border.bottom.width = NULL, - stub_group.border.bottom.color = NULL, field.border.top.style = NULL, - field.border.top.width = NULL, field.border.top.color = NULL, - field.border.bottom.style = NULL, field.border.bottom.width = NULL, - field.border.bottom.color = NULL, row.padding = NULL, + row_group.background.color = NULL, row_group.font.size = NULL, + row_group.font.weight = NULL, row_group.border.top.style = NULL, + row_group.border.top.width = NULL, row_group.border.top.color = NULL, + row_group.border.bottom.style = NULL, + row_group.border.bottom.width = NULL, + row_group.border.bottom.color = NULL, + table_body.border.top.style = NULL, + table_body.border.top.width = NULL, + table_body.border.top.color = NULL, + table_body.border.bottom.style = NULL, + table_body.border.bottom.width = NULL, + table_body.border.bottom.color = NULL, row.padding = NULL, summary_row.background.color = NULL, summary_row.padding = NULL, summary_row.text_transform = NULL, grand_summary_row.background.color = NULL, @@ -32,7 +34,7 @@ tab_options(data, table.width = NULL, table.font.size = NULL, footnote.glyph = NULL, footnote.font.size = NULL, footnote.padding = NULL, sourcenote.font.size = NULL, sourcenote.padding = NULL, row.striping.include_stub = NULL, - row.striping.include_field = NULL) + row.striping.include_table_body = NULL) } \arguments{ \item{data}{a table object that is created using the \code{\link{gt}()} @@ -45,11 +47,11 @@ given in units of pixels. The \code{\link{px}()} and \code{\link{pct}()} helper functions can also be used to pass in numeric values and obtain values as pixel or percent units.} -\item{table.font.size, heading.title.font.size, heading.subtitle.font.size, column_labels.font.size, stub_group.font.size, footnote.font.size, sourcenote.font.size}{font sizes for the parent text element \code{table} and the following child +\item{table.font.size, heading.title.font.size, heading.subtitle.font.size, column_labels.font.size, row_group.font.size, footnote.font.size, sourcenote.font.size}{font sizes for the parent text element \code{table} and the following child elements: \code{heading.title}, \code{heading.subtitle}, \code{columns}, -\code{stub_group}, \code{footnote}, and \code{sourcenote}. Can be specified -as a single-length character vector with units of pixels -(e.g., \code{12px}) or as a percentage (e.g., \code{80\%}). If provided as a +\code{row_group}, \code{footnote}, and \code{sourcenote}. Can be specified +as a single-length character vector with units of pixels (e.g., +\code{12px}) or as a percentage (e.g., \code{80\%}). If provided as a single-length numeric vector, it is assumed that the value is given in units of pixels. The \code{\link{px}()} and \code{\link{pct}()} helper functions can also be used to pass in numeric values and obtain values as @@ -67,13 +69,13 @@ code should be provided.} \item{column_labels.font.weight, stub_group.font.weight}{the font weight of the \code{columns} and \code{stub_group} text element.} -\item{stub_group.border.top.style, stub_group.border.top.width, stub_group.border.top.color}{the style, width, and color of the stub heading's top border.} +\item{row_group.border.top.style, row_group.border.top.width, row_group.border.top.color}{the style, width, and color of the row group's top border.} -\item{stub_group.border.bottom.style, stub_group.border.bottom.width, stub_group.border.bottom.color}{the style, width, and color of the stub heading's bottom border.} +\item{row_group.border.bottom.style, row_group.border.bottom.width, row_group.border.bottom.color}{the style, width, and color of the row group's bottom border.} -\item{field.border.top.style, field.border.top.width, field.border.top.color}{the style, width, and color of the field's top border.} +\item{table_body.border.top.style, table_body.border.top.width, table_body.border.top.color}{the style, width, and color of the table body's top border.} -\item{field.border.bottom.style, field.border.bottom.width, field.border.bottom.color}{the style, width, and color of the field's bottom border.} +\item{table_body.border.bottom.style, table_body.border.bottom.width, table_body.border.bottom.color}{the style, width, and color of the table body's bottom border.} \item{row.padding, summary_row.padding, grand_summary_row.padding}{the amount of padding in each row and in each type of summary row.} @@ -99,8 +101,8 @@ the footnote and source note sections.} \item{row.striping.include_stub}{an option for whether to include the stub when striping rows.} -\item{row.striping.include_field}{an option for whether to include the field -when striping rows.} +\item{row.striping.include_table_body}{an option for whether to include the +table body when striping rows.} } \value{ an object of class \code{gt_tbl}. diff --git a/man/tab_style.Rd b/man/tab_style.Rd index 905ae7e825..f9e70af555 100644 --- a/man/tab_style.Rd +++ b/man/tab_style.Rd @@ -101,7 +101,6 @@ tab_2 <- date <= "2015-12-15" ) \%>\% dplyr::select(-c(adj_close, volume)) \%>\% - dplyr::mutate(date = as.character(date)) \%>\% gt() \%>\% tab_style( style = cells_styles( diff --git a/pkgdown/favicon/apple-touch-icon-120x120.png b/pkgdown/favicon/apple-touch-icon-120x120.png old mode 100644 new mode 100755 diff --git a/pkgdown/favicon/apple-touch-icon-152x152.png b/pkgdown/favicon/apple-touch-icon-152x152.png old mode 100644 new mode 100755 diff --git a/pkgdown/favicon/apple-touch-icon-180x180.png b/pkgdown/favicon/apple-touch-icon-180x180.png old mode 100644 new mode 100755 diff --git a/pkgdown/favicon/apple-touch-icon-60x60.png b/pkgdown/favicon/apple-touch-icon-60x60.png old mode 100644 new mode 100755 diff --git a/pkgdown/favicon/apple-touch-icon-76x76.png b/pkgdown/favicon/apple-touch-icon-76x76.png old mode 100644 new mode 100755 diff --git a/pkgdown/favicon/apple-touch-icon.png b/pkgdown/favicon/apple-touch-icon.png old mode 100644 new mode 100755 diff --git a/pkgdown/favicon/favicon-16x16.png b/pkgdown/favicon/favicon-16x16.png old mode 100644 new mode 100755 diff --git a/pkgdown/favicon/favicon-32x32.png b/pkgdown/favicon/favicon-32x32.png old mode 100644 new mode 100755 diff --git a/pkgdown/favicon/favicon.ico b/pkgdown/favicon/favicon.ico old mode 100644 new mode 100755 diff --git a/tests/gt-examples/01-html-script/html-08-using_summary_rows.R b/tests/gt-examples/01-html-script/html-08-using_summary_rows.R index a0615076ed..b1ac43d895 100644 --- a/tests/gt-examples/01-html-script/html-08-using_summary_rows.R +++ b/tests/gt-examples/01-html-script/html-08-using_summary_rows.R @@ -39,7 +39,7 @@ summary_tbl <- fmt_missing(columns = vars(value, value_2)) %>% tab_options( summary_row.background.color = "#FFFEEE", - stub_group.background.color = "lightblue") + row_group.background.color = "lightblue") summary_tbl diff --git a/tests/gt-examples/01-html-script/html-16-table_options_everywhere.R b/tests/gt-examples/01-html-script/html-16-table_options_everywhere.R index 5abd5106b9..579d6702c0 100644 --- a/tests/gt-examples/01-html-script/html-16-table_options_everywhere.R +++ b/tests/gt-examples/01-html-script/html-16-table_options_everywhere.R @@ -66,24 +66,24 @@ many_options_tbl <- column_labels.font.size = px(16), # Column labels - font size column_labels.font.weight = "normal", # Column labels - font weight column_labels.background.color = "lightgray", # Column labels background color - stub_group.background.color = "green", # Stub group background color - stub_group.font.size = px(14), # Stub group labels - font size - stub_group.font.weight = "800", # Stub group labels - font weight - stub_group.border.top.style = "solid", # Top line of stub group - style - stub_group.border.top.width = px(5), # Top line of stub group - width - stub_group.border.top.color = "blue", # Top line of stub group - color - stub_group.border.bottom.style = "solid", # Bottom line of stub group - style - stub_group.border.bottom.width = px(4), # Bottom line of stub group - width - stub_group.border.bottom.color = "orange", # Bottom line of stub group - color - field.border.top.style = "solid", # Top line of field - style - field.border.top.width = px(5), # Top line of field - width - field.border.top.color = "indianred", # Top line of field - color - field.border.bottom.style = "solid", # Bottom line of field - style - field.border.bottom.width = px(5), # Bottom line of field - width - field.border.bottom.color = "turquoise", # Bottom line of field - color - row.padding = px(8), # Padding of all data rows (stub & field) - summary_row.background.color = "pink", # -- background color of all summary rows (stub & field) - summary_row.padding = px(3), # padding of all summary rows (stub & field) + row_group.background.color = "green", # Stub group background color + row_group.font.size = px(14), # Stub group labels - font size + row_group.font.weight = "800", # Stub group labels - font weight + row_group.border.top.style = "solid", # Top line of stub group - style + row_group.border.top.width = px(5), # Top line of stub group - width + row_group.border.top.color = "blue", # Top line of stub group - color + row_group.border.bottom.style = "solid", # Bottom line of stub group - style + row_group.border.bottom.width = px(4), # Bottom line of stub group - width + row_group.border.bottom.color = "orange", # Bottom line of stub group - color + table_body.border.top.style = "solid", # Top line of table body - style + table_body.border.top.width = px(5), # Top line of table body - width + table_body.border.top.color = "indianred", # Top line of table body - color + table_body.border.bottom.style = "solid", # Bottom line of table body - style + table_body.border.bottom.width = px(5), # Bottom line of table body - width + table_body.border.bottom.color = "turquoise", # Bottom line of table body - color + row.padding = px(8), # Padding of all data rows (stub & table body) + summary_row.background.color = "pink", # -- background color of all summary rows (stub & table body) + summary_row.padding = px(3), # padding of all summary rows (stub & table body) summary_row.text_transform = "lowercase", # text transform on all summary row labels footnote.font.size = px(12), # text size of the footnotes block footnote.padding = px(3), # padding of the footnotes block diff --git a/tests/gt-examples/02-html-rmd/html-08-using_summary_rows.Rmd b/tests/gt-examples/02-html-rmd/html-08-using_summary_rows.Rmd index 546edf9a6c..2ba7be9eae 100644 --- a/tests/gt-examples/02-html-rmd/html-08-using_summary_rows.Rmd +++ b/tests/gt-examples/02-html-rmd/html-08-using_summary_rows.Rmd @@ -40,19 +40,23 @@ summary_tbl <- fns = list( ~mean(., na.rm = TRUE), ~sum(., na.rm = TRUE), - ~sd(., na.rm = TRUE))) %>% + ~sd(., na.rm = TRUE)) + ) %>% tab_footnote( footnote = "Note for Summary A.", locations = cells_summary( - groups = "A", columns = 1, rows = 1)) %>% + groups = "A", columns = 1, rows = 1) + ) %>% tab_footnote( footnote = "Note for Summary C.", locations = cells_summary( - groups = "C", columns = 1, rows = 1)) %>% + groups = "C", columns = 1, rows = 1) + ) %>% fmt_missing(columns = vars(value, value_2)) %>% tab_options( summary_row.background.color = "#FFFEEE", - stub_group.background.color = "lightblue") + row_group.background.color = "lightblue" + ) ``` ```{r} diff --git a/tests/gt-examples/02-html-rmd/html-16-table_options_everywhere.Rmd b/tests/gt-examples/02-html-rmd/html-16-table_options_everywhere.Rmd index d6bdade73b..25bf726e70 100644 --- a/tests/gt-examples/02-html-rmd/html-16-table_options_everywhere.Rmd +++ b/tests/gt-examples/02-html-rmd/html-16-table_options_everywhere.Rmd @@ -79,24 +79,24 @@ gt(tbl) %>% column_labels.font.size = px(16), # Column labels - font size column_labels.font.weight = "normal", # Column labels - font weight column_labels.background.color = "lightgray", # Column labels - background color - stub_group.background.color = "green", # Stub group background color - stub_group.font.size = px(14), # Stub group labels - font size - stub_group.font.weight = "800", # Stub group labels - font weight - stub_group.border.top.style = "solid", # Top line of stub group - style - stub_group.border.top.width = px(5), # Top line of stub group - width - stub_group.border.top.color = "blue", # Top line of stub group - color - stub_group.border.bottom.style = "solid", # Bottom line of stub group - style - stub_group.border.bottom.width = px(4), # Bottom line of stub group - width - stub_group.border.bottom.color = "orange", # Bottom line of stub group - color - field.border.top.style = "solid", # Top line of field - style - field.border.top.width = px(5), # Top line of field - width - field.border.top.color = "indianred", # Top line of field - color - field.border.bottom.style = "solid", # Bottom line of field - style - field.border.bottom.width = px(5), # Bottom line of field - width - field.border.bottom.color = "turquoise", # Bottom line of field - color - row.padding = px(8), # Padding of all data rows (stub & field) - summary_row.background.color = "pink", # -- background color of all summary rows (stub & field) - summary_row.padding = px(3), # padding of all summary rows (stub & field) + row_group.background.color = "green", # Stub group background color + row_group.font.size = px(14), # Stub group labels - font size + row_group.font.weight = "800", # Stub group labels - font weight + row_group.border.top.style = "solid", # Top line of stub group - style + row_group.border.top.width = px(5), # Top line of stub group - width + row_group.border.top.color = "blue", # Top line of stub group - color + row_group.border.bottom.style = "solid", # Bottom line of stub group - style + row_group.border.bottom.width = px(4), # Bottom line of stub group - width + row_group.border.bottom.color = "orange", # Bottom line of stub group - color + table_body.border.top.style = "solid", # Top line of table body - style + table_body.border.top.width = px(5), # Top line of table body - width + table_body.border.top.color = "indianred", # Top line of table body - color + table_body.border.bottom.style = "solid", # Bottom line of table body - style + table_body.border.bottom.width = px(5), # Bottom line of table body - width + table_body.border.bottom.color = "turquoise", # Bottom line of table body - color + row.padding = px(8), # Padding of all data rows (stub & table body) + summary_row.background.color = "pink", # -- background color of all summary rows (stub & table body) + summary_row.padding = px(3), # padding of all summary rows (stub & table body) summary_row.text_transform = "lowercase", # text transform on all summary row labels footnote.font.size = px(12), # text size of the footnotes block footnote.padding = px(3), # padding of the footnotes block diff --git a/tests/gt-examples/03-latex/latex-04-sleep.Rmd b/tests/gt-examples/03-latex/latex-04-sleep.Rmd index 3f740399ae..b90e7475e2 100644 --- a/tests/gt-examples/03-latex/latex-04-sleep.Rmd +++ b/tests/gt-examples/03-latex/latex-04-sleep.Rmd @@ -19,3 +19,4 @@ gt(data = sleep) %>% footnote = "This is a footnote", locations = cells_data(columns = 1, rows = c(2, 3, 4))) ``` + diff --git a/tests/gt-examples/05-html-email/emailing_table.R b/tests/gt-examples/05-html-email/emailing_table.R index dd4f8da7fc..938b75d0c9 100644 --- a/tests/gt-examples/05-html-email/emailing_table.R +++ b/tests/gt-examples/05-html-email/emailing_table.R @@ -108,11 +108,11 @@ pizza_tab_email <- ) %>% tab_options( summary_row.background.color = "#FFFEEE", - stub_group.background.color = "#E6EFFC", + row_group.background.color = "#E6EFFC", table.font.size = "small", heading.title.font.size = "small", heading.subtitle.font.size = "x-small", - stub_group.font.size = "small", + row_group.font.size = "small", column_labels.font.size = "small", row.padding = "5px" ) %>% diff --git a/tests/testthat/helper-gt_attr_expectations.R b/tests/testthat/helper-gt_attr_expectations.R index 3e7ae0fb22..e861028a1c 100644 --- a/tests/testthat/helper-gt_attr_expectations.R +++ b/tests/testthat/helper-gt_attr_expectations.R @@ -18,7 +18,7 @@ expect_tab_colnames <- function(tab, attr(tab, "stub_df")[["rowname"]], df$rowname) - } else if (rowname == "data_frame") { + } else if (rowname == "tibble") { expect_equal( attr(tab, "stub_df")[["rowname"]], diff --git a/tests/testthat/test-conditional_fmt.R b/tests/testthat/test-conditional_fmt.R index 5f3d2038f1..fb865d5731 100644 --- a/tests/testthat/test-conditional_fmt.R +++ b/tests/testthat/test-conditional_fmt.R @@ -41,7 +41,7 @@ test_that("the `fmt_number()` function works with conditional `rows`", { rows = num_1 < 1000) %>% render_formats_test(context = "html"))[["num_1"]], c("1836.23", "2763.39", "937.2900", "643.0000", - "212.2320", "0.0000", "-23.2400")) + "212.2320", "0.0000", "−23.2400")) expect_equal( (tab %>% @@ -65,7 +65,7 @@ test_that("the `fmt_scientific()` function works with conditional `rows`", { c("1836.23", "2763.39", "9.3729 × 102", "6.4300 × 102", "2.1223 × 102", "0.0000", - "-2.3240 × 101") + "−2.3240 × 101") ) expect_equal( @@ -89,8 +89,8 @@ test_that("the `fmt_percent()` function works with conditional `rows`", { decimals = 2, rows = num_1 < 1000) %>% render_formats_test(context = "html"))[["num_1"]], - c("1836.23", "2763.39", "93,729.00%", "64,300.00%", - "21,223.20%", "0.00%", "-2,324.00%") + c("1836.23", "2763.39", "93,729.00%", "64,300.00%", + "21,223.20%", "0.00%", "−2,324.00%") ) expect_equal( @@ -100,7 +100,7 @@ test_that("the `fmt_percent()` function works with conditional `rows`", { decimals = 2, rows = char_2 %in% c("june", "july") & grepl("sa.*", char_1)) %>% render_formats_test(context = "html"))[["num_2"]], - c("3,400.00%", "74", "23", "NA", "35", "NA", "NA") + c("3,400.00%", "74", "23", "NA", "35", "NA", "NA") ) }) @@ -114,7 +114,7 @@ test_that("the `fmt_currency()` function works with conditional `rows`", { rows = num_1 < 1000) %>% render_formats_test(context = "html"))[["num_1"]], c("1836.23", "2763.39", "$937.29", "$643.00", "$212.23", - "$0.00", "$-23.24") + "$0.00", "−$23.24") ) expect_equal( diff --git a/tests/testthat/test-fmt_currency.R b/tests/testthat/test-fmt_currency.R index 6b7b721425..bf41ff1f4f 100644 --- a/tests/testthat/test-fmt_currency.R +++ b/tests/testthat/test-fmt_currency.R @@ -12,7 +12,8 @@ test_that("the `fmt_currency()` function works correctly", { "october", "november", "december"), num_1 = c(1836.23, 2763.39, 937.29, 643.00, 212.232, 0, -23.24), num_2 = c(34, 74, 23, 93, 35, 76, 57), - stringsAsFactors = FALSE) + stringsAsFactors = FALSE + ) # Create a `gt_tbl` object with `gt()` and the # `data_tbl` dataset @@ -28,7 +29,9 @@ test_that("the `fmt_currency()` function works correctly", { c("names", "class", "row.names", "boxh_df", "stub_df", "footnotes_df", "styles_df", "rows_df", "cols_df", "col_labels", "grp_labels", - "arrange_groups", "data_df", "opts_df", "formats", "transforms"))) + "arrange_groups", "data_df", "opts_df", "formats", "transforms") + ) + ) # Extract vectors from the table object for comparison # to the original dataset @@ -48,12 +51,14 @@ test_that("the `fmt_currency()` function works correctly", { # that does not exist expect_error( tab %>% - fmt_currency(columns = "num_3", currency = "USD")) + fmt_currency(columns = "num_3", currency = "USD") + ) # Expect an error when using a locale that does not exist expect_error( tab %>% - fmt_currency(columns = "num_2", decimals = 2, locale = "aa_bb")) + fmt_currency(columns = "num_2", decimals = 2, locale = "aa_bb") + ) # Format the `num_1` column using defaults (currency of "USD"); # extract `output_df` and compare to expected values @@ -61,7 +66,9 @@ test_that("the `fmt_currency()` function works correctly", { (tab %>% fmt_currency(columns = "num_1") %>% render_formats_test(context = "html"))[["num_1"]], - c("$1,836.23", "$2,763.39", "$937.29", "$643.00", "$212.23", "$0.00", "$-23.24")) + c("$1,836.23", "$2,763.39", "$937.29", "$643.00", "$212.23", + "$0.00", "−$23.24") + ) # Format the `num_1` column as USD, use all other defaults; # extract `output_df` and compare to expected values @@ -69,7 +76,9 @@ test_that("the `fmt_currency()` function works correctly", { (tab %>% fmt_currency(columns = "num_1", currency = "USD") %>% render_formats_test(context = "html"))[["num_1"]], - c("$1,836.23", "$2,763.39", "$937.29", "$643.00", "$212.23", "$0.00", "$-23.24")) + c("$1,836.23", "$2,763.39", "$937.29", "$643.00", "$212.23", + "$0.00", "−$23.24") + ) # Format the `num_1` column as USD to 5 decimal places, use all # other defaults; extract `output_df` and compare to expected values @@ -78,7 +87,8 @@ test_that("the `fmt_currency()` function works correctly", { fmt_currency(columns = "num_1", currency = "USD", decimals = 5) %>% render_formats_test("html"))[["num_1"]], c("$1,836.23000", "$2,763.39000", "$937.29000", "$643.00000", - "$212.23200", "$0.00000", "$-23.24000")) + "$212.23200", "$0.00000", "−$23.24000") + ) # Format the `num_1` column as USD, and don't include the subunits; # use all other defaults; extract `output_df` and compare to @@ -87,7 +97,8 @@ test_that("the `fmt_currency()` function works correctly", { (tab %>% fmt_currency(columns = "num_1", currency = "USD", use_subunits = FALSE) %>% render_formats_test("html"))[["num_1"]], - c("$1,836", "$2,763", "$937", "$643", "$212", "$0", "$-23")) + c("$1,836", "$2,763", "$937", "$643", "$212", "$0", "−$23") + ) # Format the `num_1` column as USD, don't use digit # grouping separators, use all other defaults; extract `output_df` @@ -96,7 +107,9 @@ test_that("the `fmt_currency()` function works correctly", { (tab %>% fmt_currency(columns = "num_1", currency = "USD", use_seps = FALSE) %>% render_formats_test("html"))[["num_1"]], - c("$1836.23", "$2763.39", "$937.29", "$643.00", "$212.23", "$0.00", "$-23.24")) + c("$1836.23", "$2763.39", "$937.29", "$643.00", "$212.23", + "$0.00", "−$23.24") + ) # Format the `num_1` column to 2 decimal places, use a single space # character as digit grouping separators, use all other defaults; @@ -105,7 +118,9 @@ test_that("the `fmt_currency()` function works correctly", { (tab %>% fmt_currency(columns = "num_1", currency = "USD", sep_mark = " ") %>% render_formats_test("html"))[["num_1"]], - c("$1 836.23", "$2 763.39", "$937.29", "$643.00", "$212.23", "$0.00", "$-23.24")) + c("$1 836.23", "$2 763.39", "$937.29", "$643.00", "$212.23", + "$0.00", "−$23.24") + ) # Format the `num_1` column as USD, use a period for the digit grouping # separators and a comma for the decimal mark, use all other defaults; @@ -116,7 +131,9 @@ test_that("the `fmt_currency()` function works correctly", { columns = "num_1", currency = "USD", sep_mark = ".", dec_mark = ",") %>% render_formats_test("html"))[["num_1"]], - c("$1.836,23", "$2.763,39", "$937,29", "$643,00", "$212,23", "$0,00", "$-23,24")) + c("$1.836,23", "$2.763,39", "$937,29", "$643,00", "$212,23", + "$0,00", "−$23,24") + ) # Format the `num_1` column as USD, apply parentheses to all negative # values, use all other defaults; extract `output_df` and compare @@ -126,7 +143,9 @@ test_that("the `fmt_currency()` function works correctly", { fmt_currency( columns = "num_1", currency = "USD", negative_val = "parens") %>% render_formats_test("html"))[["num_1"]], - c("$1,836.23", "$2,763.39", "$937.29", "$643.00", "$212.23", "$0.00", "($23.24)")) + c("$1,836.23", "$2,763.39", "$937.29", "$643.00", "$212.23", + "$0.00", "($23.24)") + ) # Format the `num_1` column as USD, apply parentheses to all negative # values, use all other defaults; apply the default context, extract @@ -136,7 +155,9 @@ test_that("the `fmt_currency()` function works correctly", { fmt_currency( columns = "num_1", currency = "USD", negative_val = "parens") %>% render_formats_test("default"))[["num_1"]], - c("$1,836.23", "$2,763.39", "$937.29", "$643.00", "$212.23", "$0.00", "($23.24)")) + c("$1,836.23", "$2,763.39", "$937.29", "$643.00", "$212.23", + "$0.00", "($23.24)") + ) # Format the `num_1` column as USD to 4 decimal places, scale all values by # 1/1000, use all other defaults; extract `output_df` and compare @@ -147,7 +168,9 @@ test_that("the `fmt_currency()` function works correctly", { columns = "num_1", currency = "USD", decimals = 4, scale_by = 1/1000) %>% render_formats_test("html"))[["num_1"]], - c("$1.8362", "$2.7634", "$0.9373", "$0.6430", "$0.2122", "$0.0000", "$-0.0232")) + c("$1.8362", "$2.7634", "$0.9373", "$0.6430", "$0.2122", + "$0.0000", "−$0.0232") + ) # Format the `num_1` column as USD, prepend and append all values by 2 # different literals, use all other defaults; extract `output_df` and @@ -158,7 +181,8 @@ test_that("the `fmt_currency()` function works correctly", { columns = "num_1", currency = "USD", pattern = "a {x} b") %>% render_formats_test("html"))[["num_1"]], c("a $1,836.23 b", "a $2,763.39 b", "a $937.29 b", "a $643.00 b", - "a $212.23 b", "a $0.00 b", "a $-23.24 b")) + "a $212.23 b", "a $0.00 b", "a −$23.24 b") + ) # Format the `num_1` column as USD to 4 decimal places, scale all values # by 1/1000 and append a `K` character to the resultant values, use @@ -170,7 +194,8 @@ test_that("the `fmt_currency()` function works correctly", { scale_by = 1/1000, pattern = "{x}K") %>% render_formats_test("html"))[["num_1"]], c("$1.8362K", "$2.7634K", "$0.9373K", "$0.6430K", - "$0.2122K", "$0.0000K", "$-0.0232K")) + "$0.2122K", "$0.0000K", "−$0.0232K") + ) # Format the `num_1` column as USD, apply the `en_US` locale and use all # other defaults; extract `output_df` and compare to expected values @@ -180,7 +205,8 @@ test_that("the `fmt_currency()` function works correctly", { columns = "num_1", currency = "USD", locale = "en_US") %>% render_formats_test("html"))[["num_1"]], c("$1,836.23", "$2,763.39", "$937.29", "$643.00", - "$212.23", "$0.00", "$-23.24")) + "$212.23", "$0.00", "−$23.24") + ) # Format the `num_1` column as DKK, apply the `da_DK` locale and use all # other defaults; extract `output_df` and compare to expected values @@ -191,7 +217,8 @@ test_that("the `fmt_currency()` function works correctly", { placement = "right", incl_space = TRUE) %>% render_formats_test("html"))[["num_1"]], c("1.836,23 kr.", "2.763,39 kr.", "937,29 kr.", "643,00 kr.", - "212,23 kr.", "0,00 kr.", "-23,24 kr.")) + "212,23 kr.", "0,00 kr.", "−23,24 kr.") + ) # Format the `num_1` column as DKK, apply the `da_DK` locale and use all # other defaults; use the default context, extract `output_df`, and @@ -202,7 +229,8 @@ test_that("the `fmt_currency()` function works correctly", { columns = "num_1", currency = "DKK", locale = "da_DK") %>% render_formats_test("default"))[["num_1"]], c("kr.1.836,23", "kr.2.763,39", "kr.937,29", "kr.643,00", - "kr.212,23", "kr.0,00", "kr.-23,24")) + "kr.212,23", "kr.0,00", "-kr.23,24") + ) # Format the `num_1` column as EUR, apply the `de_AT` locale and use all # other defaults; extract `output_df` and compare to expected values @@ -212,7 +240,8 @@ test_that("the `fmt_currency()` function works correctly", { columns = "num_1", currency = "EUR", locale = "de_AT") %>% render_formats_test("html"))[["num_1"]], c("€1 836,23", "€2 763,39", "€937,29", "€643,00", - "€212,23", "€0,00", "€-23,24")) + "€212,23", "€0,00", "−€23,24") + ) # Format the `num_1` column as EUR, apply the `de_AT` locale and use all # other defaults; use the default context, extract `output_df`, and @@ -223,7 +252,8 @@ test_that("the `fmt_currency()` function works correctly", { columns = "num_1", currency = "EUR", locale = "de_AT") %>% render_formats_test("default"))[["num_1"]], c("EUR1 836,23", "EUR2 763,39", "EUR937,29", "EUR643,00", - "EUR212,23", "EUR0,00", "EUR-23,24")) + "EUR212,23", "EUR0,00", "-EUR23,24") + ) # Format the `num_1` column to 2 decimal places, apply the `et_EE` # locale and use all other defaults; extract `output_df` and compare @@ -234,7 +264,8 @@ test_that("the `fmt_currency()` function works correctly", { columns = "num_1", currency = "EUR", locale = "et_EE") %>% render_formats_test("html"))[["num_1"]], c("€1 836,23", "€2 763,39", "€937,29", "€643,00", - "€212,23", "€0,00", "€-23,24")) + "€212,23", "€0,00", "−€23,24") + ) }) test_that("the `fmt_currency()` function can scale/suffix larger numbers", { @@ -247,7 +278,8 @@ test_that("the `fmt_currency()` function can scale/suffix larger numbers", { -1.8E15, -1.7E13, -1.6E10, -1.5E8, -1.4E6, -1.3E4, -1.2E3, -1.1E1, 0, 1.1E1, 1.2E3, 1.3E4, 1.4E6, 1.5E8, 1.6E10, 1.7E13, 1.8E15), - stringsAsFactors = FALSE) + stringsAsFactors = FALSE + ) # Create a `gt_tbl` object with `gt()` and the # `data_tbl` dataset @@ -260,9 +292,12 @@ test_that("the `fmt_currency()` function can scale/suffix larger numbers", { (tab %>% fmt_currency(columns = "num", decimals = 2, suffixing = TRUE) %>% render_formats_test(context = "html"))[["num"]], - c("$-1,800.00T", "$-17.00T", "$-16.00B", "$-150.00M", "$-1.40M", "$-13.00K", - "$-1.20K", "$-11.00", "$0.00", "$11.00", "$1.20K", "$13.00K", "$1.40M", - "$150.00M", "$16.00B", "$17.00T", "$1,800.00T")) + c("−$1,800.00T", "−$17.00T", "−$16.00B", + "−$150.00M", "−$1.40M", "−$13.00K", + "−$1.20K", "−$11.00", "$0.00", "$11.00", + "$1.20K", "$13.00K", "$1.40M", "$150.00M", "$16.00B", + "$17.00T", "$1,800.00T") + ) # Format the `num` column to no decimal places, have the # `suffixing` option set to TRUE (default labels, all @@ -271,9 +306,10 @@ test_that("the `fmt_currency()` function can scale/suffix larger numbers", { (tab %>% fmt_currency(columns = "num", decimals = 0, suffixing = TRUE) %>% render_formats_test(context = "html"))[["num"]], - c("$-1,800T", "$-17T", "$-16B", "$-150M", "$-1M", "$-13K", - "$-1K", "$-11", "$0", "$11", "$1K", "$13K", "$1M", - "$150M", "$16B", "$17T", "$1,800T")) + c("−$1,800T", "−$17T", "−$16B", "−$150M", + "−$1M", "−$13K", "−$1K", "−$11", "$0", + "$11", "$1K", "$13K", "$1M", "$150M", "$16B", "$17T", "$1,800T") + ) # Format the `num` column to 2 decimal places, have the # `suffixing` option set to use custom symbols across the @@ -284,9 +320,11 @@ test_that("the `fmt_currency()` function can scale/suffix larger numbers", { columns = "num", decimals = 2, suffixing = c("k", "Mn", "Bn", "Tr")) %>% render_formats_test(context = "html"))[["num"]], - c("$-1,800.00Tr", "$-17.00Tr", "$-16.00Bn", "$-150.00Mn", "$-1.40Mn", - "$-13.00k", "$-1.20k", "$-11.00", "$0.00", "$11.00", "$1.20k", - "$13.00k", "$1.40Mn", "$150.00Mn", "$16.00Bn", "$17.00Tr", "$1,800.00Tr")) + c("−$1,800.00Tr", "−$17.00Tr", "−$16.00Bn", + "−$150.00Mn", "−$1.40Mn", "−$13.00k", "−$1.20k", + "−$11.00", "$0.00", "$11.00", "$1.20k", "$13.00k", "$1.40Mn", + "$150.00Mn", "$16.00Bn", "$17.00Tr", "$1,800.00Tr") + ) # Format the `num` column to 2 decimal places, have the # `suffixing` option set to use custom symbols for the middle @@ -297,12 +335,14 @@ test_that("the `fmt_currency()` function can scale/suffix larger numbers", { columns = "num", decimals = 2, currency = "EUR", locale = "de_DE", suffixing = c(NA, "Mio.", "Mia.", NA)) %>% render_formats_test(context = "html"))[["num"]], - c("€-1.800.000,00Mia.", "€-17.000,00Mia.", "€-16,00Mia.", - "€-150,00Mio.", "€-1,40Mio.", "€-13.000,00", - "€-1.200,00", "€-11,00", "€0,00", "€11,00", - "€1.200,00", "€13.000,00", "€1,40Mio.", + c("−€1.800.000,00Mia.", "−€17.000,00Mia.", + "−€16,00Mia.", "−€150,00Mio.", + "−€1,40Mio.", "−€13.000,00", + "−€1.200,00", "−€11,00", "€0,00", + "€11,00", "€1.200,00", "€13.000,00", "€1,40Mio.", "€150,00Mio.", "€16,00Mia.", "€17.000,00Mia.", - "€1.800.000,00Mia.")) + "€1.800.000,00Mia.") + ) # Format the `num` column to 2 decimal places, have the # `suffixing` option set to use custom symbols with some NAs @@ -312,10 +352,12 @@ test_that("the `fmt_currency()` function can scale/suffix larger numbers", { columns = "num", decimals = 2, suffixing = c("K", NA, "Bn", NA, "Qa", NA, NA)) %>% render_formats_test(context = "html"))[["num"]], - c("$-1.80Qa", "$-17,000.00Bn", "$-16.00Bn", "$-150,000.00K", - "$-1,400.00K", "$-13.00K", "$-1.20K", "$-11.00", "$0.00", "$11.00", - "$1.20K", "$13.00K", "$1,400.00K", "$150,000.00K", "$16.00Bn", - "$17,000.00Bn", "$1.80Qa")) + c("−$1.80Qa", "−$17,000.00Bn", "−$16.00Bn", + "−$150,000.00K", "−$1,400.00K", "−$13.00K", + "−$1.20K", "−$11.00", "$0.00", "$11.00", "$1.20K", + "$13.00K", "$1,400.00K", "$150,000.00K", "$16.00Bn", + "$17,000.00Bn", "$1.80Qa") + ) # Format the `num` column to 2 decimal places, have the # `suffixing` option set to FALSE (the default option, where @@ -326,12 +368,13 @@ test_that("the `fmt_currency()` function can scale/suffix larger numbers", { columns = "num", decimals = 2, suffixing = FALSE) %>% render_formats_test(context = "html"))[["num"]], - c( "$-1,800,000,000,000,000.00", "$-17,000,000,000,000.00", - "$-16,000,000,000.00", "$-150,000,000.00", "$-1,400,000.00", - "$-13,000.00", "$-1,200.00", "$-11.00", "$0.00", "$11.00", - "$1,200.00", "$13,000.00", "$1,400,000.00", "$150,000,000.00", - "$16,000,000,000.00", "$17,000,000,000,000.00", - "$1,800,000,000,000,000.00")) + c( "−$1,800,000,000,000,000.00", "−$17,000,000,000,000.00", + "−$16,000,000,000.00", "−$150,000,000.00", + "−$1,400,000.00", "−$13,000.00", "−$1,200.00", + "−$11.00", "$0.00", "$11.00", "$1,200.00", "$13,000.00", + "$1,400,000.00", "$150,000,000.00", "$16,000,000,000.00", + "$17,000,000,000,000.00", "$1,800,000,000,000,000.00") + ) # Expect an error if any vector length other than # four is used for `suffixing` @@ -404,5 +447,4 @@ test_that("the `fmt_currency()` function can scale/suffix larger numbers", { suffixing = TRUE) %>% render_formats_test(context = "html"))[["num"]], "$999.99990") - }) diff --git a/tests/testthat/test-fmt_number.R b/tests/testthat/test-fmt_number.R index 2f0fc092fe..f0541371b3 100644 --- a/tests/testthat/test-fmt_number.R +++ b/tests/testthat/test-fmt_number.R @@ -61,7 +61,7 @@ test_that("the `fmt_number()` function works correctly", { (tab %>% fmt_number(columns = "num_1", decimals = 2) %>% render_formats_test(context = "html"))[["num_1"]], - c("1,836.23", "2,763.39", "937.29", "643.00", "212.23", "0.00", "-23.24")) + c("1,836.23", "2,763.39", "937.29", "643.00", "212.23", "0.00", "−23.24")) # Format the `num_1` column to 5 decimal places, use all # other defaults; extract `output_df` and compare to expected values @@ -70,7 +70,7 @@ test_that("the `fmt_number()` function works correctly", { fmt_number(columns = "num_1", decimals = 5) %>% render_formats_test("html"))[["num_1"]], c("1,836.23000", "2,763.39000", "937.29000", "643.00000", - "212.23200", "0.00000", "-23.24000")) + "212.23200", "0.00000", "−23.24000")) # Format the `num_1` column to 2 decimal places, drop the trailing # zeros, use all other defaults; extract `output_df` and compare to @@ -80,7 +80,7 @@ test_that("the `fmt_number()` function works correctly", { fmt_number(columns = "num_1", decimals = 2, drop_trailing_zeros = TRUE) %>% render_formats_test("html"))[["num_1"]], - c("1,836.23", "2,763.39", "937.29", "643", "212.23", "0", "-23.24")) + c("1,836.23", "2,763.39", "937.29", "643", "212.23", "0", "−23.24")) # Format the `num_1` column to 2 decimal places, don't use digit # grouping separators, use all other defaults; extract `output_df` @@ -89,7 +89,7 @@ test_that("the `fmt_number()` function works correctly", { (tab %>% fmt_number(columns = "num_1", decimals = 2, use_seps = FALSE) %>% render_formats_test("html"))[["num_1"]], - c("1836.23", "2763.39", "937.29", "643.00", "212.23", "0.00", "-23.24")) + c("1836.23", "2763.39", "937.29", "643.00", "212.23", "0.00", "−23.24")) # Format the `num_1` column to 2 decimal places, use a single space # character as digit grouping separators, use all other defaults; @@ -98,7 +98,7 @@ test_that("the `fmt_number()` function works correctly", { (tab %>% fmt_number(columns = "num_1", decimals = 2, sep_mark = " ") %>% render_formats_test("html"))[["num_1"]], - c("1 836.23", "2 763.39", "937.29", "643.00", "212.23", "0.00", "-23.24")) + c("1 836.23", "2 763.39", "937.29", "643.00", "212.23", "0.00", "−23.24")) # Format the `num_1` column to 2 decimal places, use a period for the # digit grouping separators and a comma for the decimal mark, use @@ -108,7 +108,7 @@ test_that("the `fmt_number()` function works correctly", { fmt_number(columns = "num_1", decimals = 2, sep_mark = ".", dec_mark = ",") %>% render_formats_test("html"))[["num_1"]], - c("1.836,23", "2.763,39", "937,29", "643,00", "212,23", "0,00", "-23,24")) + c("1.836,23", "2.763,39", "937,29", "643,00", "212,23", "0,00", "−23,24")) # Format the `num_1` column to 2 decimal places, apply parentheses to # all negative values, use all other defaults; extract `output_df` and @@ -117,7 +117,7 @@ test_that("the `fmt_number()` function works correctly", { (tab %>% fmt_number(columns = "num_1", decimals = 2, negative_val = "parens") %>% render_formats_test("html"))[["num_1"]], - c("1,836.23", "2,763.39", "937.29", "643.00", "212.23", "0.00", "(23.24)")) + c("1,836.23", "2,763.39", "937.29", "643.00", "212.23", "0.00", "(23.24)")) # Format the `num_1` column to 4 decimal places, scale all values by # 1/1000, use all other defaults; extract `output_df` and compare @@ -126,7 +126,7 @@ test_that("the `fmt_number()` function works correctly", { (tab %>% fmt_number(columns = "num_1", decimals = 4, scale_by = 1/1000) %>% render_formats_test("html"))[["num_1"]], - c("1.8362", "2.7634", "0.9373", "0.6430", "0.2122", "0.0000", "-0.0232")) + c("1.8362", "2.7634", "0.9373", "0.6430", "0.2122", "0.0000", "−0.0232")) # Format the `num_1` column to 2 decimal places, prepend and append # all values by 2 different literals, use all other defaults; extract @@ -136,7 +136,7 @@ test_that("the `fmt_number()` function works correctly", { fmt_number(columns = "num_1", decimals = 2, pattern = "a {x} b") %>% render_formats_test("html"))[["num_1"]], c("a 1,836.23 b", "a 2,763.39 b", "a 937.29 b", "a 643.00 b", - "a 212.23 b", "a 0.00 b", "a -23.24 b")) + "a 212.23 b", "a 0.00 b", "a −23.24 b")) # Format the `num_1` column to 4 decimal places, scale all values # by 1/1000 and append a `K` character to the resultant values, use @@ -147,7 +147,7 @@ test_that("the `fmt_number()` function works correctly", { scale_by = 1/1000, pattern = "{x}K") %>% render_formats_test("html"))[["num_1"]], c("1.8362K", "2.7634K", "0.9373K", "0.6430K", - "0.2122K", "0.0000K", "-0.0232K")) + "0.2122K", "0.0000K", "−0.0232K")) # Format the `num_1` column to 2 decimal places, apply the `en_US` # locale and use all other defaults; extract `output_df` and compare @@ -156,7 +156,7 @@ test_that("the `fmt_number()` function works correctly", { (tab %>% fmt_number(columns = "num_1", decimals = 2, locale = "en_US") %>% render_formats_test("html"))[["num_1"]], - c("1,836.23", "2,763.39", "937.29", "643.00", "212.23", "0.00", "-23.24")) + c("1,836.23", "2,763.39", "937.29", "643.00", "212.23", "0.00", "−23.24")) # Format the `num_1` column to 2 decimal places, apply the `da_DK` # locale and use all other defaults; extract `output_df` and compare @@ -165,7 +165,7 @@ test_that("the `fmt_number()` function works correctly", { (tab %>% fmt_number(columns = "num_1", decimals = 2, locale = "da_DK") %>% render_formats_test("html"))[["num_1"]], - c("1.836,23", "2.763,39", "937,29", "643,00", "212,23", "0,00", "-23,24")) + c("1.836,23", "2.763,39", "937,29", "643,00", "212,23", "0,00", "−23,24")) # Format the `num_1` column to 2 decimal places, apply the `de_AT` # locale and use all other defaults; extract `output_df` and compare @@ -174,7 +174,7 @@ test_that("the `fmt_number()` function works correctly", { (tab %>% fmt_number(columns = "num_1", decimals = 2, locale = "de_AT") %>% render_formats_test("html"))[["num_1"]], - c("1 836,23", "2 763,39", "937,29", "643,00", "212,23", "0,00", "-23,24")) + c("1 836,23", "2 763,39", "937,29", "643,00", "212,23", "0,00", "−23,24")) # Format the `num_1` column to 2 decimal places, apply the `et_EE` # locale and use all other defaults; extract `output_df` and compare @@ -183,7 +183,7 @@ test_that("the `fmt_number()` function works correctly", { (tab %>% fmt_number(columns = "num_1", decimals = 2, locale = "et_EE") %>% render_formats_test("html"))[["num_1"]], - c("1 836,23", "2 763,39", "937,29", "643,00", "212,23", "0,00", "-23,24")) + c("1 836,23", "2 763,39", "937,29", "643,00", "212,23", "0,00", "−23,24")) # Format the `num_1` column to 2 decimal places, apply the `gl_ES` # locale and use all other defaults; extract `output_df` and compare @@ -192,7 +192,7 @@ test_that("the `fmt_number()` function works correctly", { (tab %>% fmt_number(columns = "num_1", decimals = 2, locale = "gl_ES") %>% render_formats_test("html"))[["num_1"]], - c("1.836,23", "2.763,39", "937,29", "643,00", "212,23", "0,00", "-23,24")) + c("1.836,23", "2.763,39", "937,29", "643,00", "212,23", "0,00", "−23,24")) }) test_that("the `fmt_number()` function can scale/suffix larger numbers", { @@ -218,9 +218,12 @@ test_that("the `fmt_number()` function can scale/suffix larger numbers", { (tab %>% fmt_number(columns = "num", decimals = 2, suffixing = TRUE) %>% render_formats_test(context = "html"))[["num"]], - c("-1,800.00T", "-17.00T", "-16.00B", "-150.00M", "-1.40M", "-13.00K", - "-1.20K", "-11.00", "0.00", "11.00", "1.20K", "13.00K", "1.40M", - "150.00M", "16.00B", "17.00T", "1,800.00T")) + c("−1,800.00T", "−17.00T", "−16.00B", + "−150.00M", "−1.40M", "−13.00K", + "−1.20K", "−11.00", "0.00", "11.00", + "1.20K", "13.00K", "1.40M", "150.00M", "16.00B", + "17.00T", "1,800.00T") + ) # Format the `num` column to no decimal places, have the # `suffixing` option set to TRUE (default labels, all @@ -229,9 +232,9 @@ test_that("the `fmt_number()` function can scale/suffix larger numbers", { (tab %>% fmt_number(columns = "num", decimals = 0, suffixing = TRUE) %>% render_formats_test(context = "html"))[["num"]], - c("-1,800T", "-17T", "-16B", "-150M", "-1M", "-13K", - "-1K", "-11", "0", "11", "1K", "13K", "1M", - "150M", "16B", "17T", "1,800T")) + c("−1,800T", "−17T", "−16B", "−150M", + "−1M", "−13K", "−1K", "−11", "0", "11", + "1K", "13K", "1M", "150M", "16B", "17T", "1,800T")) # Format the `num` column to 2 decimal places, have the # `suffixing` option set to use custom symbols across the @@ -242,9 +245,10 @@ test_that("the `fmt_number()` function can scale/suffix larger numbers", { columns = "num", decimals = 2, suffixing = c("k", "Mn", "Bn", "Tr")) %>% render_formats_test(context = "html"))[["num"]], - c("-1,800.00Tr", "-17.00Tr", "-16.00Bn", "-150.00Mn", "-1.40Mn", "-13.00k", - "-1.20k", "-11.00", "0.00", "11.00", "1.20k", "13.00k", "1.40Mn", - "150.00Mn", "16.00Bn", "17.00Tr", "1,800.00Tr")) + c("−1,800.00Tr", "−17.00Tr", "−16.00Bn", + "−150.00Mn", "−1.40Mn", "−13.00k", + "−1.20k", "−11.00", "0.00", "11.00", "1.20k", + "13.00k", "1.40Mn", "150.00Mn", "16.00Bn", "17.00Tr", "1,800.00Tr")) # Format the `num` column to 2 decimal places, have the # `suffixing` option set to use custom symbols for the middle @@ -255,8 +259,9 @@ test_that("the `fmt_number()` function can scale/suffix larger numbers", { columns = "num", decimals = 2, suffixing = c(NA, "Mio.", "Mia.", NA)) %>% render_formats_test(context = "html"))[["num"]], - c("-1,800,000.00Mia.", "-17,000.00Mia.", "-16.00Mia.", "-150.00Mio.", - "-1.40Mio.", "-13,000.00", "-1,200.00", "-11.00", "0.00", "11.00", + c("−1,800,000.00Mia.", "−17,000.00Mia.", + "−16.00Mia.", "−150.00Mio.", "−1.40Mio.", + "−13,000.00", "−1,200.00", "−11.00", "0.00", "11.00", "1,200.00", "13,000.00", "1.40Mio.", "150.00Mio.", "16.00Mia.", "17,000.00Mia.", "1,800,000.00Mia.")) @@ -268,10 +273,10 @@ test_that("the `fmt_number()` function can scale/suffix larger numbers", { columns = "num", decimals = 2, suffixing = c("K", NA, "Bn", NA, "Qa", NA, NA)) %>% render_formats_test(context = "html"))[["num"]], - c("-1.80Qa", "-17,000.00Bn", "-16.00Bn", "-150,000.00K", - "-1,400.00K", "-13.00K", "-1.20K", "-11.00", "0.00", "11.00", - "1.20K", "13.00K", "1,400.00K", "150,000.00K", "16.00Bn", - "17,000.00Bn", "1.80Qa")) + c("−1.80Qa", "−17,000.00Bn", "−16.00Bn", + "−150,000.00K", "−1,400.00K", "−13.00K", + "−1.20K", "−11.00", "0.00", "11.00", "1.20K", "13.00K", + "1,400.00K", "150,000.00K", "16.00Bn", "17,000.00Bn", "1.80Qa")) # Format the `num` column to 2 decimal places, have the # `suffixing` option set to FALSE (the default option, where @@ -282,9 +287,10 @@ test_that("the `fmt_number()` function can scale/suffix larger numbers", { columns = "num", decimals = 2, suffixing = FALSE) %>% render_formats_test(context = "html"))[["num"]], - c("-1,800,000,000,000,000.00", "-17,000,000,000,000.00", - "-16,000,000,000.00", "-150,000,000.00", "-1,400,000.00", "-13,000.00", - "-1,200.00", "-11.00", "0.00", "11.00", "1,200.00", "13,000.00", + c("−1,800,000,000,000,000.00", "−17,000,000,000,000.00", + "−16,000,000,000.00", "−150,000,000.00", + "−1,400,000.00", "−13,000.00", "−1,200.00", + "−11.00", "0.00", "11.00", "1,200.00", "13,000.00", "1,400,000.00", "150,000,000.00", "16,000,000,000.00", "17,000,000,000,000.00", "1,800,000,000,000,000.00")) diff --git a/tests/testthat/test-fmt_percent.R b/tests/testthat/test-fmt_percent.R index c3b656b612..feb7f42f19 100644 --- a/tests/testthat/test-fmt_percent.R +++ b/tests/testthat/test-fmt_percent.R @@ -12,7 +12,8 @@ test_that("the `fmt_percent()` function works correctly", { "october", "november", "december"), num_1 = c(1836.23, 2763.39, 937.29, 643.00, 212.232, 0, -23.24), num_2 = c(34, 74, 23, 93, 35, 76, 57), - stringsAsFactors = FALSE) + stringsAsFactors = FALSE + ) # Create a `gt_tbl` object with `gt()` and the # `data_tbl` dataset @@ -22,12 +23,14 @@ test_that("the `fmt_percent()` function works correctly", { # that does not exist expect_error( tab %>% - fmt_percent(columns = "num_3", decimals = 2)) + fmt_percent(columns = "num_3", decimals = 2) + ) # Expect an error when using a locale that does not exist expect_error( tab %>% - fmt_percent(columns = "num_2", decimals = 2, locale = "aa_bb")) + fmt_percent(columns = "num_2", decimals = 2, locale = "aa_bb") + ) # Format the `num_1` column to 2 decimal places, use all # other defaults; extract `output_df` and compare to expected values @@ -35,8 +38,10 @@ test_that("the `fmt_percent()` function works correctly", { (tab %>% fmt_percent(columns = "num_1", decimals = 2) %>% render_formats_test("html"))[["num_1"]], - c("183,623.00%", "276,339.00%", "93,729.00%", - "64,300.00%", "21,223.20%", "0.00%", "-2,324.00%")) + c("183,623.00%", "276,339.00%", "93,729.00%", + "64,300.00%", "21,223.20%", "0.00%", + "−2,324.00%") + ) # Format the `num_1` column to 5 decimal places, use all # other defaults; extract `output_df` and compare to expected values @@ -44,8 +49,10 @@ test_that("the `fmt_percent()` function works correctly", { (tab %>% fmt_percent(columns = "num_1", decimals = 5) %>% render_formats_test("html"))[["num_1"]], - c("183,623.00000%", "276,339.00000%", "93,729.00000%", - "64,300.00000%", "21,223.20000%", "0.00000%", "-2,324.00000%")) + c("183,623.00000%", "276,339.00000%", "93,729.00000%", + "64,300.00000%", "21,223.20000%", "0.00000%", + "−2,324.00000%") + ) # Format the `num_1` column to 2 decimal places, drop the trailing # zeros, use all other defaults; extract `output_df` and compare to @@ -55,8 +62,9 @@ test_that("the `fmt_percent()` function works correctly", { fmt_percent(columns = "num_1", decimals = 2, drop_trailing_zeros = TRUE) %>% render_formats_test("html"))[["num_1"]], - c("183,623%", "276,339%", "93,729%", "64,300%", - "21,223.2%", "0%", "-2,324%" )) + c("183,623%", "276,339%", "93,729%", "64,300%", + "21,223.2%", "0%", "−2,324%") + ) # Format the `num_1` column to 2 decimal places, don't use digit # grouping separators, use all other defaults; extract `output_df` @@ -65,8 +73,10 @@ test_that("the `fmt_percent()` function works correctly", { (tab %>% fmt_percent(columns = "num_1", decimals = 2, use_seps = FALSE) %>% render_formats_test("html"))[["num_1"]], - c("183623.00%", "276339.00%", "93729.00%", "64300.00%", - "21223.20%", "0.00%", "-2324.00%")) + c("183623.00%", "276339.00%", "93729.00%", + "64300.00%", "21223.20%", "0.00%", + "−2324.00%") + ) # Format the `num_1` column to 2 decimal places, use a single space # character as digit grouping separators, use all other defaults; @@ -75,8 +85,10 @@ test_that("the `fmt_percent()` function works correctly", { (tab %>% fmt_percent(columns = "num_1", decimals = 2, sep_mark = " ") %>% render_formats_test("html"))[["num_1"]], - c("183 623.00%", "276 339.00%", "93 729.00%", "64 300.00%", - "21 223.20%", "0.00%", "-2 324.00%")) + c("183 623.00%", "276 339.00%", "93 729.00%", + "64 300.00%", "21 223.20%", "0.00%", + "−2 324.00%") + ) # Format the `num_1` column to 2 decimal places, use a period for the # digit grouping separators and a comma for the decimal mark, use @@ -86,8 +98,10 @@ test_that("the `fmt_percent()` function works correctly", { fmt_percent(columns = "num_1", decimals = 2, sep_mark = ".", dec_mark = ",") %>% render_formats_test("html"))[["num_1"]], - c("183.623,00%", "276.339,00%", "93.729,00%", "64.300,00%", - "21.223,20%", "0,00%", "-2.324,00%")) + c("183.623,00%", "276.339,00%", "93.729,00%", + "64.300,00%", "21.223,20%", "0,00%", + "−2.324,00%") + ) # Format the `num_1` column to 2 decimal places, apply parentheses to # all negative values, use all other defaults; extract `output_df` and @@ -96,8 +110,10 @@ test_that("the `fmt_percent()` function works correctly", { (tab %>% fmt_percent(columns = "num_1", decimals = 2, negative_val = "parens") %>% render_formats_test("html"))[["num_1"]], - c("183,623.00%", "276,339.00%", "93,729.00%", "64,300.00%", - "21,223.20%", "0.00%", "(2,324.00%)")) + c("183,623.00%", "276,339.00%", "93,729.00%", + "64,300.00%", "21,223.20%", "0.00%", + "(2,324.00%)") + ) # Format the `num_1` column to 2 decimal places, prepend and append # all values by 2 different literals, use all other defaults; extract @@ -106,8 +122,11 @@ test_that("the `fmt_percent()` function works correctly", { (tab %>% fmt_percent(columns = "num_1", decimals = 2, pattern = "a {x}:n") %>% render_formats_test("html"))[["num_1"]], - c("a 183,623.00%:n", "a 276,339.00%:n", "a 93,729.00%:n", - "a 64,300.00%:n", "a 21,223.20%:n", "a 0.00%:n", "a -2,324.00%:n")) + c("a 183,623.00%:n", "a 276,339.00%:n", + "a 93,729.00%:n", "a 64,300.00%:n", + "a 21,223.20%:n", "a 0.00%:n", + "a −2,324.00%:n") + ) # Format the `num_1` column to 0 decimal places, place a space between # the percent sign (on the right) and the value, use all other defaults; @@ -117,8 +136,10 @@ test_that("the `fmt_percent()` function works correctly", { fmt_percent(columns = "num_1", decimals = 0, placement = "right", incl_space = TRUE) %>% render_formats_test("html"))[["num_1"]], - c("183,623 %", "276,339 %", "93,729 %", "64,300 %", - "21,223 %", "0 %", "-2,324 %")) + c("183,623 %", "276,339 %", "93,729 %", + "64,300 %", "21,223 %", "0 %", + "−2,324 %") + ) # Format the `num_1` column to 0 decimal places, place a space between # the percent sign (on the left) and the value, use all other defaults; @@ -128,8 +149,10 @@ test_that("the `fmt_percent()` function works correctly", { fmt_percent(columns = "num_1", decimals = 0, placement = "left", incl_space = TRUE) %>% render_formats_test("html"))[["num_1"]], - c("% 183,623", "% 276,339", "% 93,729", "% 64,300", - "% 21,223", "% 0", "% -2,324")) + c("% 183,623", "% 276,339", "% 93,729", + "% 64,300", "% 21,223", "% 0", + "% −2,324") + ) # Format the `num_1` column to 2 decimal places, apply the `en_US` # locale and use all other defaults; extract `output_df` and compare @@ -138,8 +161,10 @@ test_that("the `fmt_percent()` function works correctly", { (tab %>% fmt_percent(columns = "num_1", decimals = 2, locale = "en_US") %>% render_formats_test("html"))[["num_1"]], - c("183,623.00%", "276,339.00%", "93,729.00%", - "64,300.00%", "21,223.20%", "0.00%", "-2,324.00%")) + c("183,623.00%", "276,339.00%", "93,729.00%", + "64,300.00%", "21,223.20%", "0.00%", + "−2,324.00%") + ) # Format the `num_1` column to 2 decimal places, apply the `da_DK` # locale and use all other defaults; extract `output_df` and compare @@ -148,8 +173,10 @@ test_that("the `fmt_percent()` function works correctly", { (tab %>% fmt_percent(columns = "num_1", decimals = 2, locale = "da_DK") %>% render_formats_test("html"))[["num_1"]], - c("183.623,00%", "276.339,00%", "93.729,00%", - "64.300,00%", "21.223,20%", "0,00%", "-2.324,00%")) + c("183.623,00%", "276.339,00%", "93.729,00%", + "64.300,00%", "21.223,20%", "0,00%", + "−2.324,00%") + ) # Format the `num_1` column to 2 decimal places, apply the `de_AT` # locale and use all other defaults; extract `output_df` and compare @@ -158,8 +185,10 @@ test_that("the `fmt_percent()` function works correctly", { (tab %>% fmt_percent(columns = "num_1", decimals = 2, locale = "de_AT") %>% render_formats_test("html"))[["num_1"]], - c("183 623,00%", "276 339,00%", "93 729,00%", - "64 300,00%", "21 223,20%", "0,00%", "-2 324,00%")) + c("183 623,00%", "276 339,00%", "93 729,00%", + "64 300,00%", "21 223,20%", "0,00%", + "−2 324,00%") + ) # Format the `num_1` column to 2 decimal places, apply the `et_EE` # locale and use all other defaults; extract `output_df` and compare @@ -168,8 +197,10 @@ test_that("the `fmt_percent()` function works correctly", { (tab %>% fmt_percent(columns = "num_1", decimals = 2, locale = "et_EE") %>% render_formats_test("html"))[["num_1"]], - c("183 623,00%", "276 339,00%", "93 729,00%", - "64 300,00%", "21 223,20%", "0,00%", "-2 324,00%")) + c("183 623,00%", "276 339,00%", "93 729,00%", + "64 300,00%", "21 223,20%", "0,00%", + "−2 324,00%") + ) # Format the `num_1` column to 2 decimal places, apply the `gl_ES` # locale and use all other defaults; extract `output_df` and compare @@ -178,6 +209,8 @@ test_that("the `fmt_percent()` function works correctly", { (tab %>% fmt_percent(columns = "num_1", decimals = 2, locale = "gl_ES") %>% render_formats_test("html"))[["num_1"]], - c("183.623,00%", "276.339,00%", "93.729,00%", - "64.300,00%", "21.223,20%", "0,00%", "-2.324,00%")) + c("183.623,00%", "276.339,00%", "93.729,00%", + "64.300,00%", "21.223,20%", "0,00%", + "−2.324,00%") + ) }) diff --git a/tests/testthat/test-fmt_scientific.R b/tests/testthat/test-fmt_scientific.R index 2eb6cc8d3f..ced4f96e51 100644 --- a/tests/testthat/test-fmt_scientific.R +++ b/tests/testthat/test-fmt_scientific.R @@ -12,7 +12,8 @@ test_that("the `fmt_scientific()` function works correctly", { "october", "november", "december"), num_1 = c(1836.23, 2763.39, 937.29, 643.00, 2.232, 0, -23.24), num_2 = c(34, 74, 23, 93, 35, 0.01, NA), - stringsAsFactors = FALSE) + stringsAsFactors = FALSE + ) # Create a `gt_tbl` object with `gt()` and the # `data_tbl` dataset @@ -25,10 +26,14 @@ test_that("the `fmt_scientific()` function works correctly", { expect_true( all( names(attributes(tab)) %in% - c("names", "class", "row.names", + c( + "names", "class", "row.names", "boxh_df", "stub_df", "footnotes_df", "styles_df", "rows_df", "cols_df", "col_labels", "grp_labels", - "arrange_groups", "data_df", "opts_df", "formats", "transforms"))) + "arrange_groups", "data_df", "opts_df", "formats", "transforms" + ) + ) + ) # Extract vectors from the table object for comparison # to the original dataset @@ -48,12 +53,14 @@ test_that("the `fmt_scientific()` function works correctly", { # that does not exist expect_error( tab %>% - fmt_scientific(columns = "num_3", decimals = 2)) + fmt_scientific(columns = "num_3", decimals = 2) + ) # Expect an error when using a locale that does not exist expect_error( tab %>% - fmt_scientific(columns = "num_2", decimals = 2, locale = "aa_bb")) + fmt_scientific(columns = "num_2", decimals = 2, locale = "aa_bb") + ) # Format the `num_1` column to 2 decimal places, use all # other defaults; extract `output_df` in the HTML context @@ -68,7 +75,9 @@ test_that("the `fmt_scientific()` function works correctly", { "9.37 × 102", "6.43 × 102", "2.23", "0.00", - "-2.32 × 101")) + "−2.32 × 101" + ) + ) # Format the `num_2` column to 2 decimal places, use all # other defaults; extract `output_df` in the HTML context @@ -83,7 +92,7 @@ test_that("the `fmt_scientific()` function works correctly", { "2.30 × 101", "9.30 × 101", "3.50 × 101", - "1.00 × 10-2", + "1.00 × 10−2", "NA" ) ) @@ -97,7 +106,9 @@ test_that("the `fmt_scientific()` function works correctly", { render_formats_test("default"))[["num_1"]], c( "1.84 x 10(3)", "2.76 x 10(3)", "9.37 x 10(2)", - "6.43 x 10(2)", "2.23", "0.00", "-2.32 x 10(1)")) + "6.43 x 10(2)", "2.23", "0.00", "-2.32 x 10(1)" + ) + ) # Format the `num_1` column to 5 decimal places, use all # other defaults; extract `output_df` in the HTML context @@ -112,7 +123,9 @@ test_that("the `fmt_scientific()` function works correctly", { "9.37290 × 102", "6.43000 × 102", "2.23200", "0.00000", - "-2.32400 × 101")) + "−2.32400 × 101" + ) + ) # Format the `num_1` column to 5 decimal places, use all # other defaults; extract `output_df` in the default context @@ -127,7 +140,9 @@ test_that("the `fmt_scientific()` function works correctly", { "9.37290 x 10(2)", "6.43000 x 10(2)", "2.23200", "0.00000", - "-2.32400 x 10(1)")) + "-2.32400 x 10(1)" + ) + ) # Format the `num_1` column to 2 decimal places, use a period for the # digit grouping separators and a comma for the decimal mark, use @@ -144,7 +159,9 @@ test_that("the `fmt_scientific()` function works correctly", { "9,37 × 102", "6,43 × 102", "2,23", "0,00", - "-2,32 × 101")) + "−2,32 × 101" + ) + ) # Format the `num_1` column to 2 decimal places, use a period for the # digit grouping separators and a comma for the decimal mark, use @@ -157,7 +174,9 @@ test_that("the `fmt_scientific()` function works correctly", { render_formats_test("default"))[["num_1"]], c( "1,84 x 10(3)", "2,76 x 10(3)", "9,37 x 10(2)", - "6,43 x 10(2)", "2,23", "0,00", "-2,32 x 10(1)")) + "6,43 x 10(2)", "2,23", "0,00", "-2,32 x 10(1)" + ) + ) # Format the `num_1` column to 4 decimal places, scale all values by # 1/1000, use all other defaults; extract `output_df` in the HTML @@ -167,12 +186,14 @@ test_that("the `fmt_scientific()` function works correctly", { fmt_scientific(columns = "num_1", decimals = 4, scale_by = 1/1000) %>% render_formats_test("html"))[["num_1"]], c( - "1.8362 × 100", - "2.7634 × 100", - "9.3729 × 10-1", - "6.4300 × 10-1", - "2.2320", "0.0000", - "-2.3240 × 10-2")) + "1.8362", "2.7634", + "9.3729 × 10−1", + "6.4300 × 10−1", + "2.2320 × 10−3", + "0.0000", + "−2.3240 × 10−2" + ) + ) # Format the `num_1` column to 4 decimal places, scale all values by # 1/1000, use all other defaults; extract `output_df` in the default @@ -181,8 +202,12 @@ test_that("the `fmt_scientific()` function works correctly", { (tab %>% fmt_scientific(columns = "num_1", decimals = 4, scale_by = 1/1000) %>% render_formats_test("default"))[["num_1"]], - c("1.8362 x 10(0)", "2.7634 x 10(0)", "9.3729 x 10(-1)", - "6.4300 x 10(-1)", "2.2320", "0.0000", "-2.3240 x 10(-2)")) + c( + "1.8362", "2.7634", "9.3729 x 10(-1)", + "6.4300 x 10(-1)", "2.2320 x 10(-3)", + "0.0000", "-2.3240 x 10(-2)" + ) + ) # Format the `num_1` column to 2 decimal places, prepend and append # all values by 2 different literals, use all other defaults; extract @@ -197,7 +222,9 @@ test_that("the `fmt_scientific()` function works correctly", { "a 9.37 × 102 b", "a 6.43 × 102 b", "a 2.23 b", "a 0.00 b", - "a -2.32 × 101 b")) + "a −2.32 × 101 b" + ) + ) # Format the `num_1` column to 2 decimal places, prepend and append # all values by 2 different literals, use all other defaults; extract @@ -208,7 +235,9 @@ test_that("the `fmt_scientific()` function works correctly", { render_formats_test("default"))[["num_1"]], c( "a 1.84 x 10(3) b", "a 2.76 x 10(3) b", "a 9.37 x 10(2) b", - "a 6.43 x 10(2) b", "a 2.23 b", "a 0.00 b", "a -2.32 x 10(1) b")) + "a 6.43 x 10(2) b", "a 2.23 b", "a 0.00 b", "a -2.32 x 10(1) b" + ) + ) # Format the `num_1` column to 2 decimal places, apply the `en_US` # locale and use all other defaults; extract `output_df` in the HTML @@ -223,7 +252,9 @@ test_that("the `fmt_scientific()` function works correctly", { "9.37 × 102", "6.43 × 102", "2.23", "0.00", - "-2.32 × 101")) + "−2.32 × 101" + ) + ) # Format the `num_1` column to 2 decimal places, apply the `da_DK` # locale and use all other defaults; extract `output_df` in the HTML @@ -238,7 +269,9 @@ test_that("the `fmt_scientific()` function works correctly", { "9,37 × 102", "6,43 × 102", "2,23", "0,00", - "-2,32 × 101")) + "−2,32 × 101" + ) + ) # Format the `num_1` column to 2 decimal places, apply the `de_AT` # locale and use all other defaults; extract `output_df` in the HTML @@ -253,7 +286,9 @@ test_that("the `fmt_scientific()` function works correctly", { "9,37 × 102", "6,43 × 102", "2,23", "0,00", - "-2,32 × 101")) + "−2,32 × 101" + ) + ) # Format the `num_1` column to 2 decimal places, apply the `et_EE` # locale and use all other defaults; extract `output_df` in the HTML @@ -268,7 +303,9 @@ test_that("the `fmt_scientific()` function works correctly", { "9,37 × 102", "6,43 × 102", "2,23", "0,00", - "-2,32 × 101")) + "−2,32 × 101" + ) + ) # Format the `num_1` column to 2 decimal places, apply the `gl_ES` # locale and use all other defaults; extract `output_df` in the HTML @@ -283,7 +320,9 @@ test_that("the `fmt_scientific()` function works correctly", { "9,37 × 102", "6,43 × 102", "2,23", "0,00", - "-2,32 × 101")) + "−2,32 × 101" + ) + ) }) test_that("`fmt_scientific()` can handle extremely large and small values", { @@ -328,13 +367,13 @@ test_that("`fmt_scientific()` can handle extremely large and small values", { fmt_scientific(columns = "num", decimals = 5) %>% render_formats_test("html"))[["num"]], c( - "-1.50000 × 10200", - "-1.50000 × 10100", - "-2.50000", - "-3.50000 × 10-100", - "-3.50000 × 10-200", - "1.50000 × 10-200", - "1.50000 × 10-100", + "−1.50000 × 10200", + "−1.50000 × 10100", + "−2.50000", + "−3.50000 × 10−100", + "−3.50000 × 10−200", + "1.50000 × 10−200", + "1.50000 × 10−100", "2.50000", "3.50000 × 10100", "3.50000 × 10200" diff --git a/tests/testthat/test-gt_object.R b/tests/testthat/test-gt_object.R index 2c35de6f95..091bb84f92 100644 --- a/tests/testthat/test-gt_object.R +++ b/tests/testthat/test-gt_object.R @@ -24,7 +24,7 @@ test_that("a gt table can be made to use the rownames of a data frame", { expect_tab_colnames( tab, df = mtcars, - rowname = "data_frame", + rowname = "tibble", groupname_is_na = TRUE) }) diff --git a/tests/testthat/test-l_conditional_fmt.R b/tests/testthat/test-l_conditional_fmt.R index 26ea18e786..71aa0a9053 100644 --- a/tests/testthat/test-l_conditional_fmt.R +++ b/tests/testthat/test-l_conditional_fmt.R @@ -10,7 +10,8 @@ data_tbl <- "october", "november", "december"), num_1 = c(1836.23, 2763.39, 937.29, 643.00, 212.232, 0, -23.24), num_2 = c(34, 74, 23, NA, 35, NA, NA), - stringsAsFactors = FALSE) + stringsAsFactors = FALSE + ) # Create a `tbl_latex` object with `gt()` and the # `data_tbl` dataset @@ -24,7 +25,8 @@ time_tbl <- time = c("16:45", "19:23", "01:30", "08:00"), datetime = c("2010-03-25 19:45", "2015-06-12 09:25", "2016-01-15 14:38", "2012-08-07 12:31"), - stringsAsFactors = FALSE) + stringsAsFactors = FALSE + ) # Create a `tbl_latex_time` object with `gt()` and the # `data_tbl` dataset @@ -39,8 +41,8 @@ test_that("the `fmt_number()` function works with conditional `rows`", { decimals = 4, rows = num_1 < 1000) %>% render_formats_test(context = "latex"))[["num_1"]], - c("1836.23", "2763.39", "937.2900", "643.0000", - "212.2320", "0.0000", "-23.2400") + c("1836.23", "2763.39", "$937.2900$", "$643.0000$", + "$212.2320$", "$0.0000$", "$-23.2400$") ) expect_equal( @@ -50,7 +52,7 @@ test_that("the `fmt_number()` function works with conditional `rows`", { decimals = 4, rows = char_2 %in% c("june", "july") & grepl("sa.*", char_1)) %>% render_formats_test(context = "latex"))[["num_2"]], - c("34.0000", "74", "23", "NA", "35", "NA", "NA") + c("$34.0000$", "74", "23", "NA", "35", "NA", "NA") ) }) @@ -63,9 +65,9 @@ test_that("the `fmt_scientific()` function works with conditional `rows`", { decimals = 4, rows = num_1 < 1000) %>% render_formats_test(context = "latex"))[["num_1"]], - c("1836.23", "2763.39", "9.3729$ \\times 10^{2}$", - "6.4300$ \\times 10^{2}$", "2.1223$ \\times 10^{2}$", "0.0000", - "-2.3240$ \\times 10^{1}$") + c("1836.23", "2763.39", "$9.3729 \\times 10^{2}$", + "$6.4300 \\times 10^{2}$", "$2.1223 \\times 10^{2}$", "$0.0000$", + "$-2.3240 \\times 10^{1}$") ) expect_equal( @@ -75,7 +77,7 @@ test_that("the `fmt_scientific()` function works with conditional `rows`", { decimals = 4, rows = char_2 %in% c("june", "july") & grepl("sa.*", char_1)) %>% render_formats_test(context = "latex"))[["num_2"]], - c("3.4000$ \\times 10^{1}$", "74", "23", "NA", "35", "NA", "NA") + c("$3.4000 \\times 10^{1}$", "74", "23", "NA", "35", "NA", "NA") ) }) @@ -88,8 +90,8 @@ test_that("the `fmt_percent()` function works with conditional `rows`", { decimals = 2, rows = num_1 < 1000) %>% render_formats_test(context = "latex"))[["num_1"]], - c("1836.23", "2763.39", "93,729.00\\%", "64,300.00\\%", - "21,223.20\\%", "0.00\\%", "-2,324.00\\%") + c("1836.23", "2763.39", "$93,729.00\\%$", "$64,300.00\\%$", + "$21,223.20\\%$", "$0.00\\%$", "$-2,324.00\\%$") ) expect_equal( @@ -99,7 +101,7 @@ test_that("the `fmt_percent()` function works with conditional `rows`", { decimals = 2, rows = char_2 %in% c("june", "july") & grepl("sa.*", char_1)) %>% render_formats_test(context = "latex"))[["num_2"]], - c("3,400.00\\%", "74", "23", "NA", "35", "NA", "NA") + c("$3,400.00\\%$", "74", "23", "NA", "35", "NA", "NA") ) }) @@ -112,8 +114,8 @@ test_that("the `fmt_currency()` function works with conditional `rows`", { currency = "USD", rows = num_1 < 1000) %>% render_formats_test(context = "latex"))[["num_1"]], - c("1836.23", "2763.39", "\\$937.29", "\\$643.00", - "\\$212.23", "\\$0.00", "\\$-23.24") + c("1836.23", "2763.39", "$\\text{\\$}937.29$", "$\\text{\\$}643.00$", + "$\\text{\\$}212.23$", "$\\text{\\$}0.00$", "$-\\text{\\$}23.24$") ) expect_equal( @@ -123,7 +125,7 @@ test_that("the `fmt_currency()` function works with conditional `rows`", { currency = "USD", rows = char_2 %in% c("june", "july") & grepl("sa.*", char_1)) %>% render_formats_test(context = "latex"))[["num_2"]], - c("\\$34.00", "74", "23", "NA", "35", "NA", "NA") + c("$\\text{\\$}34.00$", "74", "23", "NA", "35", "NA", "NA") ) }) diff --git a/tests/testthat/test-l_fmt_currency.R b/tests/testthat/test-l_fmt_currency.R index 5045b1e9f3..8fe17bbdeb 100644 --- a/tests/testthat/test-l_fmt_currency.R +++ b/tests/testthat/test-l_fmt_currency.R @@ -12,7 +12,8 @@ test_that("the `fmt_currency()` function works correctly", { "october", "november", "december"), num_1 = c(1836.23, 2763.39, 937.29, 643.00, 212.232, 0, -23.24), num_2 = c(34, 74, 23, 93, 35, 76, 57), - stringsAsFactors = FALSE) + stringsAsFactors = FALSE + ) # Create a `tbl_latex` object with `gt()` and the # `data_tbl` dataset @@ -24,8 +25,10 @@ test_that("the `fmt_currency()` function works correctly", { (tbl_latex %>% fmt_currency(columns = "num_1", currency = "USD") %>% render_formats_test(context = "latex"))[["num_1"]], - c("\\$1,836.23", "\\$2,763.39", "\\$937.29", "\\$643.00", - "\\$212.23", "\\$0.00", "\\$-23.24")) + c("$\\text{\\$}1,836.23$", "$\\text{\\$}2,763.39$", "$\\text{\\$}937.29$", + "$\\text{\\$}643.00$", "$\\text{\\$}212.23$", "$\\text{\\$}0.00$", + "$-\\text{\\$}23.24$") + ) # Format the `num_1` column as USD to 5 decimal places, use all # other defaults; extract `output_df` and compare to expected values @@ -33,8 +36,11 @@ test_that("the `fmt_currency()` function works correctly", { (tbl_latex %>% fmt_currency(columns = "num_1", currency = "USD", decimals = 5) %>% render_formats_test("latex"))[["num_1"]], - c("\\$1,836.23000", "\\$2,763.39000", "\\$937.29000", "\\$643.00000", - "\\$212.23200", "\\$0.00000", "\\$-23.24000")) + c("$\\text{\\$}1,836.23000$", "$\\text{\\$}2,763.39000$", + "$\\text{\\$}937.29000$", "$\\text{\\$}643.00000$", + "$\\text{\\$}212.23200$", "$\\text{\\$}0.00000$", + "$-\\text{\\$}23.24000$") + ) # Format the `num_1` column as USD, and don't include the subunits; # use all other defaults; extract `output_df` and compare to @@ -43,7 +49,10 @@ test_that("the `fmt_currency()` function works correctly", { (tbl_latex %>% fmt_currency(columns = "num_1", currency = "USD", use_subunits = FALSE) %>% render_formats_test("latex"))[["num_1"]], - c("\\$1,836", "\\$2,763", "\\$937", "\\$643", "\\$212", "\\$0", "\\$-23")) + c("$\\text{\\$}1,836$", "$\\text{\\$}2,763$", "$\\text{\\$}937$", + "$\\text{\\$}643$", "$\\text{\\$}212$", "$\\text{\\$}0$", + "$-\\text{\\$}23$") + ) # Format the `num_1` column as USD, don't use digit # grouping separators, use all other defaults; extract `output_df` @@ -52,8 +61,10 @@ test_that("the `fmt_currency()` function works correctly", { (tbl_latex %>% fmt_currency(columns = "num_1", currency = "USD", use_seps = FALSE) %>% render_formats_test("latex"))[["num_1"]], - c("\\$1836.23", "\\$2763.39", "\\$937.29", "\\$643.00", - "\\$212.23", "\\$0.00", "\\$-23.24")) + c("$\\text{\\$}1836.23$", "$\\text{\\$}2763.39$", "$\\text{\\$}937.29$", + "$\\text{\\$}643.00$", "$\\text{\\$}212.23$", "$\\text{\\$}0.00$", + "$-\\text{\\$}23.24$") + ) # Format the `num_1` column to 2 decimal places, use a single space # character as digit grouping separators, use all other defaults; @@ -62,8 +73,10 @@ test_that("the `fmt_currency()` function works correctly", { (tbl_latex %>% fmt_currency(columns = "num_1", currency = "USD", sep_mark = " ") %>% render_formats_test("latex"))[["num_1"]], - c("\\$1 836.23", "\\$2 763.39", "\\$937.29", "\\$643.00", - "\\$212.23", "\\$0.00", "\\$-23.24")) + c("$\\text{\\$}1 836.23$", "$\\text{\\$}2 763.39$", "$\\text{\\$}937.29$", + "$\\text{\\$}643.00$", "$\\text{\\$}212.23$", "$\\text{\\$}0.00$", + "$-\\text{\\$}23.24$") + ) # Format the `num_1` column as USD, use a period for the digit grouping # separators and a comma for the decimal mark, use all other defaults; @@ -74,8 +87,10 @@ test_that("the `fmt_currency()` function works correctly", { columns = "num_1", currency = "USD", sep_mark = ".", dec_mark = ",") %>% render_formats_test("latex"))[["num_1"]], - c("\\$1.836,23", "\\$2.763,39", "\\$937,29", "\\$643,00", - "\\$212,23", "\\$0,00", "\\$-23,24")) + c("$\\text{\\$}1.836,23$", "$\\text{\\$}2.763,39$", "$\\text{\\$}937,29$", + "$\\text{\\$}643,00$", "$\\text{\\$}212,23$", "$\\text{\\$}0,00$", + "$-\\text{\\$}23,24$") + ) # Format the `num_1` column as USD, apply parentheses to all negative # values, use all other defaults; extract `output_df` and compare @@ -85,8 +100,10 @@ test_that("the `fmt_currency()` function works correctly", { fmt_currency( columns = "num_1", currency = "USD", negative_val = "parens") %>% render_formats_test("latex"))[["num_1"]], - c("\\$1,836.23", "\\$2,763.39", "\\$937.29", "\\$643.00", - "\\$212.23", "\\$0.00", "(\\$23.24)")) + c("$\\text{\\$}1,836.23$", "$\\text{\\$}2,763.39$", "$\\text{\\$}937.29$", + "$\\text{\\$}643.00$", "$\\text{\\$}212.23$", "$\\text{\\$}0.00$", + "$\\left(\\text{\\$}23.24\\right)$") + ) # Format the `num_1` column as USD, apply parentheses to all negative # values, use all other defaults; apply the default context, extract @@ -96,8 +113,10 @@ test_that("the `fmt_currency()` function works correctly", { fmt_currency( columns = "num_1", currency = "USD", negative_val = "parens") %>% render_formats_test("latex"))[["num_1"]], - c("\\$1,836.23", "\\$2,763.39", "\\$937.29", "\\$643.00", - "\\$212.23", "\\$0.00", "(\\$23.24)")) + c("$\\text{\\$}1,836.23$", "$\\text{\\$}2,763.39$", "$\\text{\\$}937.29$", + "$\\text{\\$}643.00$", "$\\text{\\$}212.23$", "$\\text{\\$}0.00$", + "$\\left(\\text{\\$}23.24\\right)$") + ) # Format the `num_1` column as USD to 4 decimal places, scale all values by # 1/1000, use all other defaults; extract `output_df` and compare @@ -108,8 +127,10 @@ test_that("the `fmt_currency()` function works correctly", { columns = "num_1", currency = "USD", decimals = 4, scale_by = 1/1000) %>% render_formats_test("latex"))[["num_1"]], - c("\\$1.8362", "\\$2.7634", "\\$0.9373", "\\$0.6430", - "\\$0.2122", "\\$0.0000", "\\$-0.0232")) + c("$\\text{\\$}1.8362$", "$\\text{\\$}2.7634$", "$\\text{\\$}0.9373$", + "$\\text{\\$}0.6430$", "$\\text{\\$}0.2122$", "$\\text{\\$}0.0000$", + "$-\\text{\\$}0.0232$") + ) # Format the `num_1` column as USD, prepend and append all values by 2 # different literals, use all other defaults; extract `output_df` and @@ -119,8 +140,11 @@ test_that("the `fmt_currency()` function works correctly", { fmt_currency( columns = "num_1", currency = "USD", pattern = "a {x} b") %>% render_formats_test("latex"))[["num_1"]], - c("a \\$1,836.23 b", "a \\$2,763.39 b", "a \\$937.29 b", "a \\$643.00 b", - "a \\$212.23 b", "a \\$0.00 b", "a \\$-23.24 b")) + c("a $\\text{\\$}1,836.23$ b", "a $\\text{\\$}2,763.39$ b", + "a $\\text{\\$}937.29$ b", "a $\\text{\\$}643.00$ b", + "a $\\text{\\$}212.23$ b", "a $\\text{\\$}0.00$ b", + "a $-\\text{\\$}23.24$ b") + ) # Format the `num_1` column as USD to 4 decimal places, scale all values # by 1/1000 and append a `K` character to the resultant values, use @@ -131,8 +155,10 @@ test_that("the `fmt_currency()` function works correctly", { columns = "num_1", currency = "USD", decimals = 4, scale_by = 1/1000, pattern = "{x}K") %>% render_formats_test("latex"))[["num_1"]], - c("\\$1.8362K", "\\$2.7634K", "\\$0.9373K", "\\$0.6430K", - "\\$0.2122K", "\\$0.0000K", "\\$-0.0232K")) + c("$\\text{\\$}1.8362$K", "$\\text{\\$}2.7634$K", "$\\text{\\$}0.9373$K", + "$\\text{\\$}0.6430$K", "$\\text{\\$}0.2122$K", "$\\text{\\$}0.0000$K", + "$-\\text{\\$}0.0232$K") + ) # Format the `num_1` column as USD, apply the `en_US` locale and use all # other defaults; extract `output_df` and compare to expected values @@ -141,8 +167,10 @@ test_that("the `fmt_currency()` function works correctly", { fmt_currency( columns = "num_1", currency = "USD", locale = "en_US") %>% render_formats_test("latex"))[["num_1"]], - c("\\$1,836.23", "\\$2,763.39", "\\$937.29", "\\$643.00", - "\\$212.23", "\\$0.00", "\\$-23.24")) + c("$\\text{\\$}1,836.23$", "$\\text{\\$}2,763.39$", "$\\text{\\$}937.29$", + "$\\text{\\$}643.00$", "$\\text{\\$}212.23$", "$\\text{\\$}0.00$", + "$-\\text{\\$}23.24$") + ) # Format the `num_1` column as DKK, apply the `da_DK` locale and use all # other defaults; extract `output_df` and compare to expected values @@ -152,19 +180,22 @@ test_that("the `fmt_currency()` function works correctly", { columns = "num_1", currency = "DKK", locale = "da_DK", placement = "right", incl_space = TRUE) %>% render_formats_test("latex"))[["num_1"]], - c("1.836,23 kr.", "2.763,39 kr.", "937,29 kr.", "643,00 kr.", - "212,23 kr.", "0,00 kr.", "-23,24 kr.")) + c("$1.836,23 \\text{kr.}$", "$2.763,39 \\text{kr.}$", + "$937,29 \\text{kr.}$", "$643,00 \\text{kr.}$", "$212,23 \\text{kr.}$", + "$0,00 \\text{kr.}$", "$-23,24 \\text{kr.}$") + ) # Format the `num_1` column as DKK, apply the `da_DK` locale and use all - # other defaults; use the default context, extract `output_df`, and - # compare to expected values + # other defaults; extract `output_df`, and compare to expected values expect_equal( (tbl_latex %>% fmt_currency( columns = "num_1", currency = "DKK", locale = "da_DK") %>% render_formats_test("latex"))[["num_1"]], - c("kr.1.836,23", "kr.2.763,39", "kr.937,29", "kr.643,00", - "kr.212,23", "kr.0,00", "kr.-23,24")) + c("$\\text{kr.}1.836,23$", "$\\text{kr.}2.763,39$", "$\\text{kr.}937,29$", + "$\\text{kr.}643,00$", "$\\text{kr.}212,23$", "$\\text{kr.}0,00$", + "$-\\text{kr.}23,24$" ) + ) # Format the `num_1` column as EUR, apply the `de_AT` locale and use all # other defaults; extract `output_df` and compare to expected values @@ -173,8 +204,10 @@ test_that("the `fmt_currency()` function works correctly", { fmt_currency( columns = "num_1", currency = "EUR", locale = "de_AT") %>% render_formats_test("latex"))[["num_1"]], - c("EUR1 836,23", "EUR2 763,39", "EUR937,29", "EUR643,00", - "EUR212,23", "EUR0,00", "EUR-23,24")) + c("$\\text{EUR}1 836,23$", "$\\text{EUR}2 763,39$", "$\\text{EUR}937,29$", + "$\\text{EUR}643,00$", "$\\text{EUR}212,23$", "$\\text{EUR}0,00$", + "$-\\text{EUR}23,24$") + ) # Format the `num_1` column as EUR, apply the `de_AT` locale and use all # other defaults; use the default context, extract `output_df`, and @@ -184,8 +217,10 @@ test_that("the `fmt_currency()` function works correctly", { fmt_currency( columns = "num_1", currency = "EUR", locale = "de_AT") %>% render_formats_test("latex"))[["num_1"]], - c("EUR1 836,23", "EUR2 763,39", "EUR937,29", "EUR643,00", - "EUR212,23", "EUR0,00", "EUR-23,24")) + c("$\\text{EUR}1 836,23$", "$\\text{EUR}2 763,39$", "$\\text{EUR}937,29$", + "$\\text{EUR}643,00$", "$\\text{EUR}212,23$", "$\\text{EUR}0,00$", + "$-\\text{EUR}23,24$") + ) # Format the `num_1` column to 2 decimal places, apply the `et_EE` # locale and use all other defaults; extract `output_df` and compare @@ -195,6 +230,8 @@ test_that("the `fmt_currency()` function works correctly", { fmt_currency( columns = "num_1", currency = "EUR", locale = "et_EE") %>% render_formats_test("latex"))[["num_1"]], - c("EUR1 836,23", "EUR2 763,39", "EUR937,29", "EUR643,00", - "EUR212,23", "EUR0,00", "EUR-23,24")) + c("$\\text{EUR}1 836,23$", "$\\text{EUR}2 763,39$", "$\\text{EUR}937,29$", + "$\\text{EUR}643,00$", "$\\text{EUR}212,23$", "$\\text{EUR}0,00$", + "$-\\text{EUR}23,24$") + ) }) diff --git a/tests/testthat/test-l_fmt_missing.R b/tests/testthat/test-l_fmt_missing.R index 85090c8133..20230353ce 100644 --- a/tests/testthat/test-l_fmt_missing.R +++ b/tests/testthat/test-l_fmt_missing.R @@ -58,7 +58,7 @@ test_that("the `fmt_missing()` function works correctly", { ) %>% fmt_missing(columns = TRUE) %>% render_formats_test(context = "latex"))[["num_1"]], - c("---", "74.000", "---", "93.000", "---", "76.000", "---")) + c("---", "$74.000$", "---", "$93.000$", "---", "$76.000$", "---")) # Reverse the ordering: use `fmt_missing()` first # then `fmt_number()`; expect the same output as before @@ -70,5 +70,5 @@ test_that("the `fmt_missing()` function works correctly", { decimals = 3 ) %>% render_formats_test(context = "latex"))[["num_1"]], - c("---", "74.000", "---", "93.000", "---", "76.000", "---")) + c("---", "$74.000$", "---", "$93.000$", "---", "$76.000$", "---")) }) diff --git a/tests/testthat/test-l_fmt_number.R b/tests/testthat/test-l_fmt_number.R index 787f79b290..bb980cafc9 100644 --- a/tests/testthat/test-l_fmt_number.R +++ b/tests/testthat/test-l_fmt_number.R @@ -12,7 +12,8 @@ test_that("the `fmt_number()` function works correctly", { "october", "november", "december"), num_1 = c(1836.23, 2763.39, 937.29, 643.00, 212.232, 0, -23.24), num_2 = c(34, 74, 23, 93, 35, 76, 57), - stringsAsFactors = FALSE) + stringsAsFactors = FALSE + ) # Create a `tbl_latex` object with `gt()` and the # `data_tbl` dataset @@ -24,7 +25,9 @@ test_that("the `fmt_number()` function works correctly", { (tbl_latex %>% fmt_number(columns = "num_1", decimals = 2) %>% render_formats_test(context = "latex"))[["num_1"]], - c("1,836.23", "2,763.39", "937.29", "643.00", "212.23", "0.00", "-23.24")) + c("$1,836.23$", "$2,763.39$", "$937.29$", "$643.00$", + "$212.23$", "$0.00$", "$-23.24$") + ) # Format the `num_1` column to 5 decimal places, use all # other defaults; extract `output_df` and compare to expected values @@ -32,18 +35,23 @@ test_that("the `fmt_number()` function works correctly", { (tbl_latex %>% fmt_number(columns = "num_1", decimals = 5) %>% render_formats_test("latex"))[["num_1"]], - c("1,836.23000", "2,763.39000", "937.29000", "643.00000", - "212.23200", "0.00000", "-23.24000")) + c("$1,836.23000$", "$2,763.39000$", "$937.29000$", + "$643.00000$", "$212.23200$", "$0.00000$", "$-23.24000$") + ) # Format the `num_1` column to 2 decimal places, drop the trailing # zeros, use all other defaults; extract `output_df` and compare to # expected values expect_equal( (tbl_latex %>% - fmt_number(columns = "num_1", decimals = 2, - drop_trailing_zeros = TRUE) %>% + fmt_number( + columns = "num_1", decimals = 2, + drop_trailing_zeros = TRUE + ) %>% render_formats_test("latex"))[["num_1"]], - c("1,836.23", "2,763.39", "937.29", "643", "212.23", "0", "-23.24")) + c("$1,836.23$", "$2,763.39$", "$937.29$", "$643$", + "$212.23$", "$0$", "$-23.24$") + ) # Format the `num_1` column to 2 decimal places, don't use digit # grouping separators, use all other defaults; extract `output_df` @@ -52,7 +60,9 @@ test_that("the `fmt_number()` function works correctly", { (tbl_latex %>% fmt_number(columns = "num_1", decimals = 2, use_seps = FALSE) %>% render_formats_test("latex"))[["num_1"]], - c("1836.23", "2763.39", "937.29", "643.00", "212.23", "0.00", "-23.24")) + c("$1836.23$", "$2763.39$", "$937.29$", "$643.00$", + "$212.23$", "$0.00$", "$-23.24$") + ) # Format the `num_1` column to 2 decimal places, use a single space # character as digit grouping separators, use all other defaults; @@ -61,17 +71,23 @@ test_that("the `fmt_number()` function works correctly", { (tbl_latex %>% fmt_number(columns = "num_1", decimals = 2, sep_mark = " ") %>% render_formats_test("latex"))[["num_1"]], - c("1 836.23", "2 763.39", "937.29", "643.00", "212.23", "0.00", "-23.24")) + c("$1 836.23$", "$2 763.39$", "$937.29$", "$643.00$", + "$212.23$", "$0.00$", "$-23.24$") + ) # Format the `num_1` column to 2 decimal places, use a period for the # digit grouping separators and a comma for the decimal mark, use # all other defaults; extract `output_df` and compare to expected values expect_equal( (tbl_latex %>% - fmt_number(columns = "num_1", decimals = 2, - sep_mark = ".", dec_mark = ",") %>% + fmt_number( + columns = "num_1", decimals = 2, + sep_mark = ".", dec_mark = "," + ) %>% render_formats_test("latex"))[["num_1"]], - c("1.836,23", "2.763,39", "937,29", "643,00", "212,23", "0,00", "-23,24")) + c("$1.836,23$", "$2.763,39$", "$937,29$", "$643,00$", + "$212,23$", "$0,00$", "$-23,24$") + ) # Format the `num_1` column to 2 decimal places, apply parentheses to # all negative values, use all other defaults; extract `output_df` and @@ -80,7 +96,9 @@ test_that("the `fmt_number()` function works correctly", { (tbl_latex %>% fmt_number(columns = "num_1", decimals = 2, negative_val = "parens") %>% render_formats_test("latex"))[["num_1"]], - c("1,836.23", "2,763.39", "937.29", "643.00", "212.23", "0.00", "(23.24)")) + c("$1,836.23$", "$2,763.39$", "$937.29$", "$643.00$", + "$212.23$", "$0.00$", "$(23.24)$") + ) # Format the `num_1` column to 4 decimal places, scale all values by # 1/1000, use all other defaults; extract `output_df` and compare @@ -89,7 +107,9 @@ test_that("the `fmt_number()` function works correctly", { (tbl_latex %>% fmt_number(columns = "num_1", decimals = 4, scale_by = 1/1000) %>% render_formats_test("latex"))[["num_1"]], - c("1.8362", "2.7634", "0.9373", "0.6430", "0.2122", "0.0000", "-0.0232")) + c("$1.8362$", "$2.7634$", "$0.9373$", "$0.6430$", "$0.2122$", + "$0.0000$", "$-0.0232$") + ) # Format the `num_1` column to 2 decimal places, prepend and append # all values by 2 different literals, use all other defaults; extract @@ -98,8 +118,9 @@ test_that("the `fmt_number()` function works correctly", { (tbl_latex %>% fmt_number(columns = "num_1", decimals = 2, pattern = "a {x} b") %>% render_formats_test("latex"))[["num_1"]], - c("a 1,836.23 b", "a 2,763.39 b", "a 937.29 b", "a 643.00 b", - "a 212.23 b", "a 0.00 b", "a -23.24 b")) + c("a $1,836.23$ b", "a $2,763.39$ b", "a $937.29$ b", "a $643.00$ b", + "a $212.23$ b", "a $0.00$ b", "a $-23.24$ b") + ) # Format the `num_1` column to 4 decimal places, scale all values # by 1/1000 and append a `K` character to the resultant values, use @@ -109,8 +130,9 @@ test_that("the `fmt_number()` function works correctly", { fmt_number(columns = "num_1", decimals = 4, scale_by = 1/1000, pattern = "{x}K") %>% render_formats_test("latex"))[["num_1"]], - c("1.8362K", "2.7634K", "0.9373K", "0.6430K", - "0.2122K", "0.0000K", "-0.0232K")) + c("$1.8362$K", "$2.7634$K", "$0.9373$K", "$0.6430$K", + "$0.2122$K", "$0.0000$K", "$-0.0232$K") + ) # Format the `num_1` column to 2 decimal places, apply the `en_US` # locale and use all other defaults; extract `output_df` and compare @@ -119,7 +141,9 @@ test_that("the `fmt_number()` function works correctly", { (tbl_latex %>% fmt_number(columns = "num_1", decimals = 2, locale = "en_US") %>% render_formats_test("latex"))[["num_1"]], - c("1,836.23", "2,763.39", "937.29", "643.00", "212.23", "0.00", "-23.24")) + c("$1,836.23$", "$2,763.39$", "$937.29$", "$643.00$", + "$212.23$", "$0.00$", "$-23.24$") + ) # Format the `num_1` column to 2 decimal places, apply the `da_DK` # locale and use all other defaults; extract `output_df` and compare @@ -128,7 +152,9 @@ test_that("the `fmt_number()` function works correctly", { (tbl_latex %>% fmt_number(columns = "num_1", decimals = 2, locale = "da_DK") %>% render_formats_test("latex"))[["num_1"]], - c("1.836,23", "2.763,39", "937,29", "643,00", "212,23", "0,00", "-23,24")) + c("$1.836,23$", "$2.763,39$", "$937,29$", "$643,00$", + "$212,23$", "$0,00$", "$-23,24$") + ) # Format the `num_1` column to 2 decimal places, apply the `de_AT` # locale and use all other defaults; extract `output_df` and compare @@ -137,7 +163,9 @@ test_that("the `fmt_number()` function works correctly", { (tbl_latex %>% fmt_number(columns = "num_1", decimals = 2, locale = "de_AT") %>% render_formats_test("latex"))[["num_1"]], - c("1 836,23", "2 763,39", "937,29", "643,00", "212,23", "0,00", "-23,24")) + c("$1 836,23$", "$2 763,39$", "$937,29$", "$643,00$", + "$212,23$", "$0,00$", "$-23,24$") + ) # Format the `num_1` column to 2 decimal places, apply the `et_EE` # locale and use all other defaults; extract `output_df` and compare @@ -146,7 +174,9 @@ test_that("the `fmt_number()` function works correctly", { (tbl_latex %>% fmt_number(columns = "num_1", decimals = 2, locale = "et_EE") %>% render_formats_test("latex"))[["num_1"]], - c("1 836,23", "2 763,39", "937,29", "643,00", "212,23", "0,00", "-23,24")) + c("$1 836,23$", "$2 763,39$", "$937,29$", "$643,00$", + "$212,23$", "$0,00$", "$-23,24$") + ) # Format the `num_1` column to 2 decimal places, apply the `gl_ES` # locale and use all other defaults; extract `output_df` and compare @@ -155,5 +185,7 @@ test_that("the `fmt_number()` function works correctly", { (tbl_latex %>% fmt_number(columns = "num_1", decimals = 2, locale = "gl_ES") %>% render_formats_test("latex"))[["num_1"]], - c("1.836,23", "2.763,39", "937,29", "643,00", "212,23", "0,00", "-23,24")) + c("$1.836,23$", "$2.763,39$", "$937,29$", "$643,00$", + "$212,23$", "$0,00$", "$-23,24$") + ) }) diff --git a/tests/testthat/test-l_fmt_percent.R b/tests/testthat/test-l_fmt_percent.R index f8d64a3ad6..20d7d4c8e5 100644 --- a/tests/testthat/test-l_fmt_percent.R +++ b/tests/testthat/test-l_fmt_percent.R @@ -12,7 +12,8 @@ test_that("the `fmt_percent()` function works correctly", { "october", "november", "december"), num_1 = c(1836.23, 2763.39, 937.29, 643.00, 212.232, 0, -23.24), num_2 = c(34, 74, 23, 93, 35, 76, 57), - stringsAsFactors = FALSE) + stringsAsFactors = FALSE + ) # Create a `tbl_latex` object with `gt()` and the # `data_tbl` dataset @@ -24,8 +25,9 @@ test_that("the `fmt_percent()` function works correctly", { (tbl_latex %>% fmt_percent(columns = "num_1", decimals = 2) %>% render_formats_test("latex"))[["num_1"]], - c("183,623.00\\%", "276,339.00\\%", "93,729.00\\%", - "64,300.00\\%", "21,223.20\\%", "0.00\\%", "-2,324.00\\%")) + c("$183,623.00\\%$", "$276,339.00\\%$", "$93,729.00\\%$", + "$64,300.00\\%$", "$21,223.20\\%$", "$0.00\\%$", "$-2,324.00\\%$") + ) # Format the `num_1` column to 5 decimal places, use all # other defaults; extract `output_df` and compare to expected values @@ -33,19 +35,24 @@ test_that("the `fmt_percent()` function works correctly", { (tbl_latex %>% fmt_percent(columns = "num_1", decimals = 5) %>% render_formats_test("latex"))[["num_1"]], - c("183,623.00000\\%", "276,339.00000\\%", "93,729.00000\\%", - "64,300.00000\\%", "21,223.20000\\%", "0.00000\\%", "-2,324.00000\\%")) + c("$183,623.00000\\%$", "$276,339.00000\\%$", "$93,729.00000\\%$", + "$64,300.00000\\%$", "$21,223.20000\\%$", "$0.00000\\%$", + "$-2,324.00000\\%$") + ) # Format the `num_1` column to 2 decimal places, drop the trailing # zeros, use all other defaults; extract `output_df` and compare to # expected values expect_equal( (tbl_latex %>% - fmt_percent(columns = "num_1", decimals = 2, - drop_trailing_zeros = TRUE) %>% + fmt_percent( + columns = "num_1", decimals = 2, + drop_trailing_zeros = TRUE + ) %>% render_formats_test("latex"))[["num_1"]], - c("183,623\\%", "276,339\\%", "93,729\\%", "64,300\\%", - "21,223.2\\%", "0\\%", "-2,324\\%" )) + c("$183,623\\%$", "$276,339\\%$", "$93,729\\%$", "$64,300\\%$", + "$21,223.2\\%$", "$0\\%$", "$-2,324\\%$") + ) # Format the `num_1` column to 2 decimal places, don't use digit # grouping separators, use all other defaults; extract `output_df` @@ -54,8 +61,9 @@ test_that("the `fmt_percent()` function works correctly", { (tbl_latex %>% fmt_percent(columns = "num_1", decimals = 2, use_seps = FALSE) %>% render_formats_test("latex"))[["num_1"]], - c("183623.00\\%", "276339.00\\%", "93729.00\\%", "64300.00\\%", - "21223.20\\%", "0.00\\%", "-2324.00\\%")) + c("$183623.00\\%$", "$276339.00\\%$", "$93729.00\\%$", "$64300.00\\%$", + "$21223.20\\%$", "$0.00\\%$", "$-2324.00\\%$") + ) # Format the `num_1` column to 2 decimal places, use a single space # character as digit grouping separators, use all other defaults; @@ -64,19 +72,23 @@ test_that("the `fmt_percent()` function works correctly", { (tbl_latex %>% fmt_percent(columns = "num_1", decimals = 2, sep_mark = " ") %>% render_formats_test("latex"))[["num_1"]], - c("183 623.00\\%", "276 339.00\\%", "93 729.00\\%", "64 300.00\\%", - "21 223.20\\%", "0.00\\%", "-2 324.00\\%")) + c("$183 623.00\\%$", "$276 339.00\\%$", "$93 729.00\\%$", "$64 300.00\\%$", + "$21 223.20\\%$", "$0.00\\%$", "$-2 324.00\\%$") + ) # Format the `num_1` column to 2 decimal places, use a period for the # digit grouping separators and a comma for the decimal mark, use # all other defaults; extract `output_df` and compare to expected values expect_equal( (tbl_latex %>% - fmt_percent(columns = "num_1", decimals = 2, - sep_mark = ".", dec_mark = ",") %>% + fmt_percent( + columns = "num_1", decimals = 2, + sep_mark = ".", dec_mark = "," + ) %>% render_formats_test("latex"))[["num_1"]], - c("183.623,00\\%", "276.339,00\\%", "93.729,00\\%", "64.300,00\\%", - "21.223,20\\%", "0,00\\%", "-2.324,00\\%")) + c("$183.623,00\\%$", "$276.339,00\\%$", "$93.729,00\\%$", "$64.300,00\\%$", + "$21.223,20\\%$", "$0,00\\%$", "$-2.324,00\\%$") + ) # Format the `num_1` column to 2 decimal places, apply parentheses to # all negative values, use all other defaults; extract `output_df` and @@ -85,8 +97,9 @@ test_that("the `fmt_percent()` function works correctly", { (tbl_latex %>% fmt_percent(columns = "num_1", decimals = 2, negative_val = "parens") %>% render_formats_test("latex"))[["num_1"]], - c("183,623.00\\%", "276,339.00\\%", "93,729.00\\%", "64,300.00\\%", - "21,223.20\\%", "0.00\\%", "(2,324.00\\%)")) + c("$183,623.00\\%$", "$276,339.00\\%$", "$93,729.00\\%$", "$64,300.00\\%$", + "$21,223.20\\%$", "$0.00\\%$", "$\\left(2,324.00\\%\\right)$") + ) # Format the `num_1` column to 2 decimal places, prepend and append # all values by 2 different literals, use all other defaults; extract @@ -95,30 +108,38 @@ test_that("the `fmt_percent()` function works correctly", { (tbl_latex %>% fmt_percent(columns = "num_1", decimals = 2, pattern = "a {x}:n") %>% render_formats_test("latex"))[["num_1"]], - c("a 183,623.00\\%:n", "a 276,339.00\\%:n", "a 93,729.00\\%:n", - "a 64,300.00\\%:n", "a 21,223.20\\%:n", "a 0.00\\%:n", "a -2,324.00\\%:n")) + c("a $183,623.00\\%$:n", "a $276,339.00\\%$:n", "a $93,729.00\\%$:n", + "a $64,300.00\\%$:n", "a $21,223.20\\%$:n", "a $0.00\\%$:n", + "a $-2,324.00\\%$:n") + ) # Format the `num_1` column to 0 decimal places, place a space between # the percent sign (on the right) and the value, use all other defaults; # extract `output_df` and compare to expected values expect_equal( (tbl_latex %>% - fmt_percent(columns = "num_1", decimals = 0, - placement = "right", incl_space = TRUE) %>% + fmt_percent( + columns = "num_1", decimals = 0, + placement = "right", incl_space = TRUE + ) %>% render_formats_test("latex"))[["num_1"]], - c("183,623 \\%", "276,339 \\%", "93,729 \\%", "64,300 \\%", - "21,223 \\%", "0 \\%", "-2,324 \\%")) + c("$183,623 \\%$", "$276,339 \\%$", "$93,729 \\%$", "$64,300 \\%$", + "$21,223 \\%$", "$0 \\%$", "$-2,324 \\%$") + ) # Format the `num_1` column to 0 decimal places, place a space between # the percent sign (on the left) and the value, use all other defaults; # extract `output_df` and compare to expected values expect_equal( (tbl_latex %>% - fmt_percent(columns = "num_1", decimals = 0, - placement = "left", incl_space = TRUE) %>% + fmt_percent( + columns = "num_1", decimals = 0, + placement = "left", incl_space = TRUE + ) %>% render_formats_test("latex"))[["num_1"]], - c("\\% 183,623", "\\% 276,339", "\\% 93,729", "\\% 64,300", - "\\% 21,223", "\\% 0", "\\% -2,324")) + c("$\\% 183,623$", "$\\% 276,339$", "$\\% 93,729$", "$\\% 64,300$", + "$\\% 21,223$", "$\\% 0$", "$\\% -2,324$") + ) # Format the `num_1` column to 2 decimal places, apply the `en_US` # locale and use all other defaults; extract `output_df` and compare @@ -127,8 +148,9 @@ test_that("the `fmt_percent()` function works correctly", { (tbl_latex %>% fmt_percent(columns = "num_1", decimals = 2, locale = "en_US") %>% render_formats_test("latex"))[["num_1"]], - c("183,623.00\\%", "276,339.00\\%", "93,729.00\\%", - "64,300.00\\%", "21,223.20\\%", "0.00\\%", "-2,324.00\\%")) + c("$183,623.00\\%$", "$276,339.00\\%$", "$93,729.00\\%$", + "$64,300.00\\%$", "$21,223.20\\%$", "$0.00\\%$", "$-2,324.00\\%$") + ) # Format the `num_1` column to 2 decimal places, apply the `da_DK` # locale and use all other defaults; extract `output_df` and compare @@ -137,8 +159,9 @@ test_that("the `fmt_percent()` function works correctly", { (tbl_latex %>% fmt_percent(columns = "num_1", decimals = 2, locale = "da_DK") %>% render_formats_test("latex"))[["num_1"]], - c("183.623,00\\%", "276.339,00\\%", "93.729,00\\%", - "64.300,00\\%", "21.223,20\\%", "0,00\\%", "-2.324,00\\%")) + c("$183.623,00\\%$", "$276.339,00\\%$", "$93.729,00\\%$", + "$64.300,00\\%$", "$21.223,20\\%$", "$0,00\\%$", "$-2.324,00\\%$") + ) # Format the `num_1` column to 2 decimal places, apply the `de_AT` # locale and use all other defaults; extract `output_df` and compare @@ -147,8 +170,9 @@ test_that("the `fmt_percent()` function works correctly", { (tbl_latex %>% fmt_percent(columns = "num_1", decimals = 2, locale = "de_AT") %>% render_formats_test("latex"))[["num_1"]], - c("183 623,00\\%", "276 339,00\\%", "93 729,00\\%", - "64 300,00\\%", "21 223,20\\%", "0,00\\%", "-2 324,00\\%")) + c("$183 623,00\\%$", "$276 339,00\\%$", "$93 729,00\\%$", + "$64 300,00\\%$", "$21 223,20\\%$", "$0,00\\%$", "$-2 324,00\\%$") + ) # Format the `num_1` column to 2 decimal places, apply the `et_EE` # locale and use all other defaults; extract `output_df` and compare @@ -157,8 +181,9 @@ test_that("the `fmt_percent()` function works correctly", { (tbl_latex %>% fmt_percent(columns = "num_1", decimals = 2, locale = "et_EE") %>% render_formats_test("latex"))[["num_1"]], - c("183 623,00\\%", "276 339,00\\%", "93 729,00\\%", - "64 300,00\\%", "21 223,20\\%", "0,00\\%", "-2 324,00\\%")) + c("$183 623,00\\%$", "$276 339,00\\%$", "$93 729,00\\%$", + "$64 300,00\\%$", "$21 223,20\\%$", "$0,00\\%$", "$-2 324,00\\%$") + ) # Format the `num_1` column to 2 decimal places, apply the `gl_ES` # locale and use all other defaults; extract `output_df` and compare @@ -167,6 +192,7 @@ test_that("the `fmt_percent()` function works correctly", { (tbl_latex %>% fmt_percent(columns = "num_1", decimals = 2, locale = "gl_ES") %>% render_formats_test("latex"))[["num_1"]], - c("183.623,00\\%", "276.339,00\\%", "93.729,00\\%", - "64.300,00\\%", "21.223,20\\%", "0,00\\%", "-2.324,00\\%")) + c("$183.623,00\\%$", "$276.339,00\\%$", "$93.729,00\\%$", + "$64.300,00\\%$", "$21.223,20\\%$", "$0,00\\%$", "$-2.324,00\\%$") + ) }) diff --git a/tests/testthat/test-l_fmt_scientific.R b/tests/testthat/test-l_fmt_scientific.R index 572ea2e3dd..de8b210c95 100644 --- a/tests/testthat/test-l_fmt_scientific.R +++ b/tests/testthat/test-l_fmt_scientific.R @@ -12,7 +12,8 @@ test_that("the `fmt_scientific()` function works correctly", { "october", "november", "december"), num_1 = c(1836.23, 2763.39, 937.29, 643.00, 2.232, 0, -23.24), num_2 = c(34, 74, 23, 93, 35, 76, 57), - stringsAsFactors = FALSE) + stringsAsFactors = FALSE + ) # Create a `tbl_latex` object with `gt()` and the # `data_tbl` dataset @@ -26,9 +27,10 @@ test_that("the `fmt_scientific()` function works correctly", { fmt_scientific(columns = "num_1", decimals = 2) %>% render_formats_test("latex"))[["num_1"]], c( - "1.84$ \\times 10^{3}$", "2.76$ \\times 10^{3}$", - "9.37$ \\times 10^{2}$", "6.43$ \\times 10^{2}$", - "2.23", "0.00", "-2.32$ \\times 10^{1}$")) + "$1.84 \\times 10^{3}$", "$2.76 \\times 10^{3}$", + "$9.37 \\times 10^{2}$", "$6.43 \\times 10^{2}$", + "$2.23$", "$0.00$", "$-2.32 \\times 10^{1}$") + ) # Format the `num_1` column to 5 decimal places, use all # other defaults; extract `output_df` in the HTML context @@ -38,9 +40,10 @@ test_that("the `fmt_scientific()` function works correctly", { fmt_scientific(columns = "num_1", decimals = 5) %>% render_formats_test("latex"))[["num_1"]], c( - "1.83623$ \\times 10^{3}$", "2.76339$ \\times 10^{3}$", - "9.37290$ \\times 10^{2}$", "6.43000$ \\times 10^{2}$", - "2.23200", "0.00000", "-2.32400$ \\times 10^{1}$")) + "$1.83623 \\times 10^{3}$", "$2.76339 \\times 10^{3}$", + "$9.37290 \\times 10^{2}$", "$6.43000 \\times 10^{2}$", + "$2.23200$", "$0.00000$", "$-2.32400 \\times 10^{1}$") + ) # Format the `num_1` column to 2 decimal places, use a period for the # digit grouping separators and a comma for the decimal mark, use @@ -48,13 +51,16 @@ test_that("the `fmt_scientific()` function works correctly", { # compare to expected values expect_equal( (tbl_latex %>% - fmt_scientific(columns = "num_1", decimals = 2, - sep_mark = ".", dec_mark = ",") %>% + fmt_scientific( + columns = "num_1", decimals = 2, + sep_mark = ".", dec_mark = "," + ) %>% render_formats_test("latex"))[["num_1"]], c( - "1,84$ \\times 10^{3}$", "2,76$ \\times 10^{3}$", - "9,37$ \\times 10^{2}$", "6,43$ \\times 10^{2}$", - "2,23", "0,00", "-2,32$ \\times 10^{1}$")) + "$1,84 \\times 10^{3}$", "$2,76 \\times 10^{3}$", + "$9,37 \\times 10^{2}$", "$6,43 \\times 10^{2}$", + "$2,23$", "$0,00$", "$-2,32 \\times 10^{1}$") + ) # Format the `num_1` column to 4 decimal places, scale all values by # 1/1000, use all other defaults; extract `output_df` in the HTML @@ -64,9 +70,10 @@ test_that("the `fmt_scientific()` function works correctly", { fmt_scientific(columns = "num_1", decimals = 4, scale_by = 1/1000) %>% render_formats_test("latex"))[["num_1"]], c( - "1.8362$ \\times 10^{0}$", "2.7634$ \\times 10^{0}$", - "9.3729$ \\times 10^{-1}$", "6.4300$ \\times 10^{-1}$", - "2.2320", "0.0000", "-2.3240$ \\times 10^{-2}$")) + "$1.8362$", "$2.7634$", + "$9.3729 \\times 10^{-1}$", "$6.4300 \\times 10^{-1}$", + "$2.2320 \\times 10^{-3}$", "$0.0000$", "$-2.3240 \\times 10^{-2}$") + ) # Format the `num_1` column to 2 decimal places, prepend and append # all values by 2 different literals, use all other defaults; extract @@ -76,9 +83,10 @@ test_that("the `fmt_scientific()` function works correctly", { fmt_scientific(columns = "num_1", decimals = 2, pattern = "a {x} b") %>% render_formats_test("latex"))[["num_1"]], c( - "a 1.84$ \\times 10^{3}$ b", "a 2.76$ \\times 10^{3}$ b", - "a 9.37$ \\times 10^{2}$ b", "a 6.43$ \\times 10^{2}$ b", - "a 2.23 b", "a 0.00 b", "a -2.32$ \\times 10^{1}$ b")) + "a $1.84 \\times 10^{3}$ b", "a $2.76 \\times 10^{3}$ b", + "a $9.37 \\times 10^{2}$ b", "a $6.43 \\times 10^{2}$ b", + "a $2.23$ b", "a $0.00$ b", "a $-2.32 \\times 10^{1}$ b") + ) # Format the `num_1` column to 2 decimal places, apply the `en_US` # locale and use all other defaults; extract `output_df` in the HTML @@ -88,9 +96,10 @@ test_that("the `fmt_scientific()` function works correctly", { fmt_scientific(columns = "num_1", decimals = 2, locale = "en_US") %>% render_formats_test("latex"))[["num_1"]], c( - "1.84$ \\times 10^{3}$", "2.76$ \\times 10^{3}$", - "9.37$ \\times 10^{2}$", "6.43$ \\times 10^{2}$", - "2.23", "0.00", "-2.32$ \\times 10^{1}$")) + "$1.84 \\times 10^{3}$", "$2.76 \\times 10^{3}$", + "$9.37 \\times 10^{2}$", "$6.43 \\times 10^{2}$", + "$2.23$", "$0.00$", "$-2.32 \\times 10^{1}$") + ) # Format the `num_1` column to 2 decimal places, apply the `da_DK` # locale and use all other defaults; extract `output_df` in the HTML @@ -100,9 +109,10 @@ test_that("the `fmt_scientific()` function works correctly", { fmt_scientific(columns = "num_1", decimals = 2, locale = "da_DK") %>% render_formats_test("latex"))[["num_1"]], c( - "1,84$ \\times 10^{3}$", "2,76$ \\times 10^{3}$", - "9,37$ \\times 10^{2}$", "6,43$ \\times 10^{2}$", - "2,23", "0,00", "-2,32$ \\times 10^{1}$")) + "$1,84 \\times 10^{3}$", "$2,76 \\times 10^{3}$", + "$9,37 \\times 10^{2}$", "$6,43 \\times 10^{2}$", + "$2,23$", "$0,00$", "$-2,32 \\times 10^{1}$") + ) # Format the `num_1` column to 2 decimal places, apply the `de_AT` # locale and use all other defaults; extract `output_df` in the HTML @@ -112,9 +122,10 @@ test_that("the `fmt_scientific()` function works correctly", { fmt_scientific(columns = "num_1", decimals = 2, locale = "de_AT") %>% render_formats_test("latex"))[["num_1"]], c( - "1,84$ \\times 10^{3}$", "2,76$ \\times 10^{3}$", - "9,37$ \\times 10^{2}$", "6,43$ \\times 10^{2}$", - "2,23", "0,00", "-2,32$ \\times 10^{1}$")) + "$1,84 \\times 10^{3}$", "$2,76 \\times 10^{3}$", + "$9,37 \\times 10^{2}$", "$6,43 \\times 10^{2}$", + "$2,23$", "$0,00$", "$-2,32 \\times 10^{1}$") + ) # Format the `num_1` column to 2 decimal places, apply the `et_EE` # locale and use all other defaults; extract `output_df` in the HTML @@ -124,9 +135,10 @@ test_that("the `fmt_scientific()` function works correctly", { fmt_scientific(columns = "num_1", decimals = 2, locale = "et_EE") %>% render_formats_test("latex"))[["num_1"]], c( - "1,84$ \\times 10^{3}$", "2,76$ \\times 10^{3}$", - "9,37$ \\times 10^{2}$", "6,43$ \\times 10^{2}$", - "2,23", "0,00", "-2,32$ \\times 10^{1}$")) + "$1,84 \\times 10^{3}$", "$2,76 \\times 10^{3}$", + "$9,37 \\times 10^{2}$", "$6,43 \\times 10^{2}$", + "$2,23$", "$0,00$", "$-2,32 \\times 10^{1}$") + ) # Format the `num_1` column to 2 decimal places, apply the `gl_ES` # locale and use all other defaults; extract `output_df` in the HTML @@ -136,7 +148,8 @@ test_that("the `fmt_scientific()` function works correctly", { fmt_scientific(columns = "num_1", decimals = 2, locale = "gl_ES") %>% render_formats_test("latex"))[["num_1"]], c( - "1,84$ \\times 10^{3}$", "2,76$ \\times 10^{3}$", - "9,37$ \\times 10^{2}$", "6,43$ \\times 10^{2}$", - "2,23", "0,00", "-2,32$ \\times 10^{1}$")) + "$1,84 \\times 10^{3}$", "$2,76 \\times 10^{3}$", + "$9,37 \\times 10^{2}$", "$6,43 \\times 10^{2}$", + "$2,23$", "$0,00$", "$-2,32 \\times 10^{1}$") + ) }) diff --git a/tests/testthat/test-tab_options.R b/tests/testthat/test-tab_options.R index 6cbe2189f2..089d5735a7 100644 --- a/tests/testthat/test-tab_options.R +++ b/tests/testthat/test-tab_options.R @@ -309,204 +309,204 @@ test_that("the internal `opts_df` table can be correctly modified", { dplyr::filter(parameter == "column_labels_background_color") %>% dplyr::pull(value)) %>% expect_equal(c(NA_character_, "lightgray")) - # Modify the `stub_group.background.color` - tbl_html <- data %>% tab_options(stub_group.background.color = "green") + # Modify the `row_group.background.color` + tbl_html <- data %>% tab_options(row_group.background.color = "green") # Compare before and after values c(opts_df_1 %>% - dplyr::filter(parameter == "stub_group_background_color") %>% dplyr::pull(value), + dplyr::filter(parameter == "row_group_background_color") %>% dplyr::pull(value), attr(tbl_html, "opts_df", exact = TRUE) %>% - dplyr::filter(parameter == "stub_group_background_color") %>% dplyr::pull(value)) %>% + dplyr::filter(parameter == "row_group_background_color") %>% dplyr::pull(value)) %>% expect_equal(c(NA_character_, "green")) - # Modify the `stub_group.font.size` - tbl_html <- data %>% tab_options(stub_group.font.size = px(18)) + # Modify the `row_group.font.size` + tbl_html <- data %>% tab_options(row_group.font.size = px(18)) # Compare before and after values c(opts_df_1 %>% - dplyr::filter(parameter == "stub_group_font_size") %>% dplyr::pull(value), + dplyr::filter(parameter == "row_group_font_size") %>% dplyr::pull(value), attr(tbl_html, "opts_df", exact = TRUE) %>% - dplyr::filter(parameter == "stub_group_font_size") %>% dplyr::pull(value)) %>% + dplyr::filter(parameter == "row_group_font_size") %>% dplyr::pull(value)) %>% expect_equal(c("16px", "18px")) - # Modify the `stub_group.font.size` option using just a numeric value - tbl_html <- data %>% tab_options(stub_group.font.size = 18) + # Modify the `row_group.font.size` option using just a numeric value + tbl_html <- data %>% tab_options(row_group.font.size = 18) # Compare before and after values c(opts_df_1 %>% - dplyr::filter(parameter == "stub_group_font_size") %>% dplyr::pull(value), + dplyr::filter(parameter == "row_group_font_size") %>% dplyr::pull(value), attr(tbl_html, "opts_df", exact = TRUE) %>% - dplyr::filter(parameter == "stub_group_font_size") %>% dplyr::pull(value)) %>% + dplyr::filter(parameter == "row_group_font_size") %>% dplyr::pull(value)) %>% expect_equal(c("16px", "18px")) - # Modify the `stub_group.font.weight` - tbl_html <- data %>% tab_options(stub_group.font.weight = "800") + # Modify the `row_group.font.weight` + tbl_html <- data %>% tab_options(row_group.font.weight = "800") # Compare before and after values c(opts_df_1 %>% - dplyr::filter(parameter == "stub_group_font_weight") %>% dplyr::pull(value), + dplyr::filter(parameter == "row_group_font_weight") %>% dplyr::pull(value), attr(tbl_html, "opts_df", exact = TRUE) %>% - dplyr::filter(parameter == "stub_group_font_weight") %>% dplyr::pull(value)) %>% + dplyr::filter(parameter == "row_group_font_weight") %>% dplyr::pull(value)) %>% expect_equal(c("initial", "800")) - # Modify the `stub_group.border.top.style` - tbl_html <- data %>% tab_options(stub_group.border.top.style = "dashed") + # Modify the `row_group.border.top.style` + tbl_html <- data %>% tab_options(row_group.border.top.style = "dashed") # Compare before and after values c(opts_df_1 %>% - dplyr::filter(parameter == "stub_group_border_top_style") %>% dplyr::pull(value), + dplyr::filter(parameter == "row_group_border_top_style") %>% dplyr::pull(value), attr(tbl_html, "opts_df", exact = TRUE) %>% - dplyr::filter(parameter == "stub_group_border_top_style") %>% dplyr::pull(value)) %>% + dplyr::filter(parameter == "row_group_border_top_style") %>% dplyr::pull(value)) %>% expect_equal(c("solid", "dashed")) - # Modify the `stub_group.border.top.width` - tbl_html <- data %>% tab_options(stub_group.border.top.width = px(5)) + # Modify the `row_group.border.top.width` + tbl_html <- data %>% tab_options(row_group.border.top.width = px(5)) # Compare before and after values c(opts_df_1 %>% - dplyr::filter(parameter == "stub_group_border_top_width") %>% dplyr::pull(value), + dplyr::filter(parameter == "row_group_border_top_width") %>% dplyr::pull(value), attr(tbl_html, "opts_df", exact = TRUE) %>% - dplyr::filter(parameter == "stub_group_border_top_width") %>% dplyr::pull(value)) %>% + dplyr::filter(parameter == "row_group_border_top_width") %>% dplyr::pull(value)) %>% expect_equal(c("2px", "5px")) - # Modify the `stub_group.border.top.width` option using just a numeric value - tbl_html <- data %>% tab_options(stub_group.border.top.width = 5) + # Modify the `row_group.border.top.width` option using just a numeric value + tbl_html <- data %>% tab_options(row_group.border.top.width = 5) # Compare before and after values c(opts_df_1 %>% - dplyr::filter(parameter == "stub_group_border_top_width") %>% dplyr::pull(value), + dplyr::filter(parameter == "row_group_border_top_width") %>% dplyr::pull(value), attr(tbl_html, "opts_df", exact = TRUE) %>% - dplyr::filter(parameter == "stub_group_border_top_width") %>% dplyr::pull(value)) %>% + dplyr::filter(parameter == "row_group_border_top_width") %>% dplyr::pull(value)) %>% expect_equal(c("2px", "5px")) - # Modify the `stub_group.border.top.color` - tbl_html <- data %>% tab_options(stub_group.border.top.color = "blue") + # Modify the `row_group.border.top.color` + tbl_html <- data %>% tab_options(row_group.border.top.color = "blue") # Compare before and after values c(opts_df_1 %>% - dplyr::filter(parameter == "stub_group_border_top_color") %>% dplyr::pull(value), + dplyr::filter(parameter == "row_group_border_top_color") %>% dplyr::pull(value), attr(tbl_html, "opts_df", exact = TRUE) %>% - dplyr::filter(parameter == "stub_group_border_top_color") %>% dplyr::pull(value)) %>% + dplyr::filter(parameter == "row_group_border_top_color") %>% dplyr::pull(value)) %>% expect_equal(c("#A8A8A8", "blue")) - # Modify the `stub_group.border.bottom.style` - tbl_html <- data %>% tab_options(stub_group.border.bottom.style = "dashed") + # Modify the `row_group.border.bottom.style` + tbl_html <- data %>% tab_options(row_group.border.bottom.style = "dashed") # Compare before and after values c(opts_df_1 %>% - dplyr::filter(parameter == "stub_group_border_bottom_style") %>% dplyr::pull(value), + dplyr::filter(parameter == "row_group_border_bottom_style") %>% dplyr::pull(value), attr(tbl_html, "opts_df", exact = TRUE) %>% - dplyr::filter(parameter == "stub_group_border_bottom_style") %>% dplyr::pull(value)) %>% + dplyr::filter(parameter == "row_group_border_bottom_style") %>% dplyr::pull(value)) %>% expect_equal(c("solid", "dashed")) - # Modify the `stub_group.border.bottom.width` - tbl_html <- data %>% tab_options(stub_group.border.bottom.width = px(4)) + # Modify the `row_group.border.bottom.width` + tbl_html <- data %>% tab_options(row_group.border.bottom.width = px(4)) # Compare before and after values c(opts_df_1 %>% - dplyr::filter(parameter == "stub_group_border_bottom_width") %>% dplyr::pull(value), + dplyr::filter(parameter == "row_group_border_bottom_width") %>% dplyr::pull(value), attr(tbl_html, "opts_df", exact = TRUE) %>% - dplyr::filter(parameter == "stub_group_border_bottom_width") %>% dplyr::pull(value)) %>% + dplyr::filter(parameter == "row_group_border_bottom_width") %>% dplyr::pull(value)) %>% expect_equal(c("2px", "4px")) - # Modify the `stub_group.border.bottom.width` option using just a numeric value - tbl_html <- data %>% tab_options(stub_group.border.bottom.width = 4) + # Modify the `row_group.border.bottom.width` option using just a numeric value + tbl_html <- data %>% tab_options(row_group.border.bottom.width = 4) # Compare before and after values c(opts_df_1 %>% - dplyr::filter(parameter == "stub_group_border_bottom_width") %>% dplyr::pull(value), + dplyr::filter(parameter == "row_group_border_bottom_width") %>% dplyr::pull(value), attr(tbl_html, "opts_df", exact = TRUE) %>% - dplyr::filter(parameter == "stub_group_border_bottom_width") %>% dplyr::pull(value)) %>% + dplyr::filter(parameter == "row_group_border_bottom_width") %>% dplyr::pull(value)) %>% expect_equal(c("2px", "4px")) - # Modify the `stub_group.border.bottom.color` - tbl_html <- data %>% tab_options(stub_group.border.bottom.color = "orange") + # Modify the `row_group.border.bottom.color` + tbl_html <- data %>% tab_options(row_group.border.bottom.color = "orange") # Compare before and after values c(opts_df_1 %>% - dplyr::filter(parameter == "stub_group_border_bottom_color") %>% dplyr::pull(value), + dplyr::filter(parameter == "row_group_border_bottom_color") %>% dplyr::pull(value), attr(tbl_html, "opts_df", exact = TRUE) %>% - dplyr::filter(parameter == "stub_group_border_bottom_color") %>% dplyr::pull(value)) %>% + dplyr::filter(parameter == "row_group_border_bottom_color") %>% dplyr::pull(value)) %>% expect_equal(c("#A8A8A8", "orange")) - # Modify the `field.border.top.style` - tbl_html <- data %>% tab_options(field.border.top.style = "dotted") + # Modify the `table_body.border.top.style` + tbl_html <- data %>% tab_options(table_body.border.top.style = "dotted") # Compare before and after values c(opts_df_1 %>% - dplyr::filter(parameter == "field_border_top_style") %>% dplyr::pull(value), + dplyr::filter(parameter == "table_body_border_top_style") %>% dplyr::pull(value), attr(tbl_html, "opts_df", exact = TRUE) %>% - dplyr::filter(parameter == "field_border_top_style") %>% dplyr::pull(value)) %>% + dplyr::filter(parameter == "table_body_border_top_style") %>% dplyr::pull(value)) %>% expect_equal(c("solid", "dotted")) - # Modify the `field.border.top.width` - tbl_html <- data %>% tab_options(field.border.top.width = px(5)) + # Modify the `table_body.border.top.width` + tbl_html <- data %>% tab_options(table_body.border.top.width = px(5)) # Compare before and after values c(opts_df_1 %>% - dplyr::filter(parameter == "field_border_top_width") %>% dplyr::pull(value), + dplyr::filter(parameter == "table_body_border_top_width") %>% dplyr::pull(value), attr(tbl_html, "opts_df", exact = TRUE) %>% - dplyr::filter(parameter == "field_border_top_width") %>% dplyr::pull(value)) %>% + dplyr::filter(parameter == "table_body_border_top_width") %>% dplyr::pull(value)) %>% expect_equal(c("2px", "5px")) - # Modify the `field.border.top.width` option using just a numeric value - tbl_html <- data %>% tab_options(field.border.top.width = 5) + # Modify the `table_body.border.top.width` option using just a numeric value + tbl_html <- data %>% tab_options(table_body.border.top.width = 5) # Compare before and after values c(opts_df_1 %>% - dplyr::filter(parameter == "field_border_top_width") %>% dplyr::pull(value), + dplyr::filter(parameter == "table_body_border_top_width") %>% dplyr::pull(value), attr(tbl_html, "opts_df", exact = TRUE) %>% - dplyr::filter(parameter == "field_border_top_width") %>% dplyr::pull(value)) %>% + dplyr::filter(parameter == "table_body_border_top_width") %>% dplyr::pull(value)) %>% expect_equal(c("2px", "5px")) - # Modify the `field.border.top.color` - tbl_html <- data %>% tab_options(field.border.top.color = "red") + # Modify the `table_body.border.top.color` + tbl_html <- data %>% tab_options(table_body.border.top.color = "red") # Compare before and after values c(opts_df_1 %>% - dplyr::filter(parameter == "field_border_top_color") %>% dplyr::pull(value), + dplyr::filter(parameter == "table_body_border_top_color") %>% dplyr::pull(value), attr(tbl_html, "opts_df", exact = TRUE) %>% - dplyr::filter(parameter == "field_border_top_color") %>% dplyr::pull(value)) %>% + dplyr::filter(parameter == "table_body_border_top_color") %>% dplyr::pull(value)) %>% expect_equal(c("#A8A8A8", "red")) - # Modify the `field.border.bottom.style` - tbl_html <- data %>% tab_options(field.border.bottom.style = "dotted") + # Modify the `table_body.border.bottom.style` + tbl_html <- data %>% tab_options(table_body.border.bottom.style = "dotted") # Compare before and after values c(opts_df_1 %>% - dplyr::filter(parameter == "field_border_bottom_style") %>% dplyr::pull(value), + dplyr::filter(parameter == "table_body_border_bottom_style") %>% dplyr::pull(value), attr(tbl_html, "opts_df", exact = TRUE) %>% - dplyr::filter(parameter == "field_border_bottom_style") %>% dplyr::pull(value)) %>% + dplyr::filter(parameter == "table_body_border_bottom_style") %>% dplyr::pull(value)) %>% expect_equal(c("solid", "dotted")) - # Modify the `field.border.bottom.width` - tbl_html <- data %>% tab_options(field.border.bottom.width = px(5)) + # Modify the `table_body.border.bottom.width` + tbl_html <- data %>% tab_options(table_body.border.bottom.width = px(5)) # Compare before and after values c(opts_df_1 %>% - dplyr::filter(parameter == "field_border_bottom_width") %>% dplyr::pull(value), + dplyr::filter(parameter == "table_body_border_bottom_width") %>% dplyr::pull(value), attr(tbl_html, "opts_df", exact = TRUE) %>% - dplyr::filter(parameter == "field_border_bottom_width") %>% dplyr::pull(value)) %>% + dplyr::filter(parameter == "table_body_border_bottom_width") %>% dplyr::pull(value)) %>% expect_equal(c("2px", "5px")) - # Modify the `field.border.bottom.width` option using just a numeric value - tbl_html <- data %>% tab_options(field.border.bottom.width = 5) + # Modify the `table_body.border.bottom.width` option using just a numeric value + tbl_html <- data %>% tab_options(table_body.border.bottom.width = 5) # Compare before and after values c(opts_df_1 %>% - dplyr::filter(parameter == "field_border_bottom_width") %>% dplyr::pull(value), + dplyr::filter(parameter == "table_body_border_bottom_width") %>% dplyr::pull(value), attr(tbl_html, "opts_df", exact = TRUE) %>% - dplyr::filter(parameter == "field_border_bottom_width") %>% dplyr::pull(value)) %>% + dplyr::filter(parameter == "table_body_border_bottom_width") %>% dplyr::pull(value)) %>% expect_equal(c("2px", "5px")) - # Modify the `field.border.bottom.color` - tbl_html <- data %>% tab_options(field.border.bottom.color = "red") + # Modify the `table_body.border.bottom.color` + tbl_html <- data %>% tab_options(table_body.border.bottom.color = "red") # Compare before and after values c(opts_df_1 %>% - dplyr::filter(parameter == "field_border_bottom_color") %>% dplyr::pull(value), + dplyr::filter(parameter == "table_body_border_bottom_color") %>% dplyr::pull(value), attr(tbl_html, "opts_df", exact = TRUE) %>% - dplyr::filter(parameter == "field_border_bottom_color") %>% dplyr::pull(value)) %>% + dplyr::filter(parameter == "table_body_border_bottom_color") %>% dplyr::pull(value)) %>% expect_equal(c("#A8A8A8", "red")) # Modify the `row.padding` @@ -659,14 +659,14 @@ test_that("the internal `opts_df` table can be correctly modified", { dplyr::filter(parameter == "row_striping_include_stub") %>% dplyr::pull(value)) %>% expect_equal(c("TRUE", "FALSE")) - # Modify the `row.striping.include_field` option - tbl_html <- data %>% tab_options(row.striping.include_field = FALSE) + # Modify the `row.striping.include_table_body` option + tbl_html <- data %>% tab_options(row.striping.include_table_body = FALSE) # Compare before and after values c(opts_df_1 %>% - dplyr::filter(parameter == "row_striping_include_field") %>% dplyr::pull(value), + dplyr::filter(parameter == "row_striping_include_table_body") %>% dplyr::pull(value), attr(tbl_html, "opts_df", exact = TRUE) %>% - dplyr::filter(parameter == "row_striping_include_field") %>% dplyr::pull(value)) %>% + dplyr::filter(parameter == "row_striping_include_table_body") %>% dplyr::pull(value)) %>% expect_equal(c("TRUE", "FALSE")) # Modify the `footnote.glyph` option diff --git a/tests/testthat/test-util_functions.R b/tests/testthat/test-util_functions.R index c596c92962..442f4feb84 100644 --- a/tests/testthat/test-util_functions.R +++ b/tests/testthat/test-util_functions.R @@ -80,54 +80,46 @@ test_that("the `get_time_format()` function works correctly", { c("%H:%M:%S", "%H:%M", "%I:%M:%S %P", "%I:%M %P", "%I %P")) }) -test_that("the `is_currency_valid()` function works correctly", { +test_that("the `validate_currency()` function works correctly", { # Expect that specific currency names supplied to - # `is_currency_valid()` will all return TRUE - lapply(currency_symbols$curr_symbol, is_currency_valid) %>% - unlist() %>% - all() %>% - expect_true() + # `validate_currency()` will all return NULL + expect_null( + lapply(currency_symbols$curr_symbol, validate_currency) %>% + unlist() + ) # Expect that invalid currency names supplied to - # `is_currency_valid()` will all return FALSE - lapply(c("thaler", "tetarteron"), is_currency_valid) %>% - unlist() %>% - all() %>% - expect_false() + # `validate_currency()` will result in an error + expect_error(lapply(c("thaler", "tetarteron"), validate_currency)) + # Expect that specific currency codes supplied to - # `is_currency_valid()` will all return TRUE - lapply(currencies$curr_code, is_currency_valid) %>% - unlist() %>% - all() %>% - expect_true() + # `validate_currency()` will all return NULL + expect_null( + lapply(currencies$curr_code, validate_currency) %>% + unlist() + ) # Expect that invalid currency codes supplied to - # `is_currency_valid()` will all return FALSE - lapply(c("AAA", "ZZZ"), is_currency_valid) %>% - unlist() %>% - all() %>% - expect_false() + # `validate_currency()` will result in an error + expect_error(lapply(c("AAA", "ZZZ"), validate_currency)) # Expect that specific currency codes (3-number) - # supplied to `is_currency_valid()` will all return TRUE - lapply(currencies$curr_number, is_currency_valid) %>% - unlist() %>% - all() %>% - expect_true() + # supplied to `validate_currency()` will return NULL + expect_null( + lapply(currencies$curr_number, validate_currency) %>% + unlist() + ) - lapply(as.numeric(currencies$curr_number), is_currency_valid) %>% - unlist() %>% - all() %>% - expect_true() + expect_null( + lapply(as.numeric(currencies$curr_number), validate_currency) %>% + unlist() + ) # Expect that invalid currency codes supplied to - # `is_currency_valid()` will all return FALSE - lapply(c(999, 998), is_currency_valid) %>% - unlist() %>% - all() %>% - expect_false() + # `validate_currency()` will return an error + expect_error(lapply(c(999, 998), validate_currency)) }) test_that("the `get_currency_str()` function works correctly", { @@ -260,26 +252,6 @@ test_that("the `get_currency_exponent()` function works correctly", { expect_equal(rep(0, 7)) }) -test_that("the `get_locale_sep_mark()` function works correctly", { - - # Expect that `get_locale_sep_mark()` will return - # different group separator symbols with specific locale IDs - lapply(c("af", "be", "en_GB", "et", "fr_FR", "ru", "th", "de"), - get_locale_sep_mark) %>% - unlist() %>% - expect_equal(c(" ", " ", ",", " ", " ", " ", ",", ".")) -}) - -test_that("the `get_locale_dec_mark()` function works correctly", { - - # Expect that `get_locale_dec_mark()` will return - # different decimal separator symbols with specific locale IDs - lapply(c("af", "be", "en_GB", "et", "fr_FR", "ru", "th", "de"), - get_locale_dec_mark) %>% - unlist() %>% - expect_equal(c(",", ",", ".", ",", ",", ",", ".", ",")) -}) - test_that("the `process_text()` function works correctly", { # Create the `simple_text` variable, which is text @@ -320,21 +292,30 @@ test_that("the `process_text()` function works correctly", { process_text(text = html_text) %>% expect_is(c("html", "character")) }) -test_that("the `get_pre_post_txt()` function works correctly", { +test_that("the `apply_pattern_fmt_x()` function works correctly", { + + # Set formatted values in a character vector + x <- c("23.4%", "32.6%", "9.15%") - # Expect that various patterns will yield the expected - # length-2 character vectors - get_pre_post_txt(pattern = "{x}") %>% - expect_equal(c("", "")) + # Expect that the default pattern `{x}` does not + # modify the values in `x` + apply_pattern_fmt_x(pattern = "{x}", values = x) %>% + expect_equal(x) - get_pre_post_txt(pattern = "a {x} b") %>% - expect_equal(c("a ", " b")) + # Expect that a pattern that appends literal text + # will work + apply_pattern_fmt_x(pattern = "{x}:n", values = x) %>% + expect_equal(paste0(x, ":n")) - get_pre_post_txt(pattern = "\\a {x} \\b") %>% - expect_equal(c("\\a ", " \\b")) + # Expect that a pattern that appends and prepends + # literal text will work + apply_pattern_fmt_x(pattern = "+{x}:n", values = x) %>% + expect_equal(paste0("+", x, ":n")) - get_pre_post_txt(pattern = "{x}....") %>% - expect_equal(c("", "....")) + # Expect that multiple instances of `{x}` will + # create copies of `x` within the output strings + apply_pattern_fmt_x(pattern = "{x}, ({x})", values = x) %>% + expect_equal(paste0(x, ", (", x, ")")) }) test_that("the `remove_html()` function works correctly", { diff --git a/tests/testthat/test-utils_formatters.R b/tests/testthat/test-utils_formatters.R new file mode 100644 index 0000000000..9f1639208b --- /dev/null +++ b/tests/testthat/test-utils_formatters.R @@ -0,0 +1,306 @@ +context("Ensuring that the utility functions for the formatters work correctly") + +test_that("the `filter_table_to_value()` function works correctly", { + + # Expect that filtering the `locales` table with + # `filter_table_to_value()` will return a single value + # so long as the filtering expressions are well chosen + expect_equal( + locales %>% + filter_table_to_value(lang, base_locale_id == "en_US"), + "en" + ) + + # Expect an error with `filter_table_to_value()` if the + # chosen filtering expressions result in a number of + # returned rows not equal to 1 + expect_error( + locales %>% + filter_table_to_value(base_locale_id, lang == "en") + ) +}) + +test_that("the `get_locale_sep_mark()` function works correctly", { + + # Expect that a `locale` which is `NULL` will return the + # default value + expect_equal( + c( + get_locale_sep_mark(locale = NULL, default = ",", use_seps = TRUE), + get_locale_sep_mark(locale = NULL, default = ".", use_seps = TRUE), + get_locale_sep_mark(locale = NULL, default = " ", use_seps = TRUE) + ), + c(",", ".", " ") + ) + + # Expect that an invalid `locale` will result in + # an error + expect_error( + get_locale_sep_mark(locale = "do_IT", default = ",", use_seps = TRUE) + ) + + # Expect that when `use_seps` is `FALSE`, we always + # get an empty string `""` returned + expect_equal( + get_locale_sep_mark(locale = "en_US", default = ",", use_seps = FALSE), + get_locale_sep_mark(locale = "do_IT", default = ",", use_seps = FALSE), + get_locale_sep_mark(locale = NULL, default = ",", use_seps = FALSE), + get_locale_sep_mark(locale = NULL, use_seps = FALSE), + get_locale_sep_mark(use_seps = FALSE), + "" + ) + + # Expect the correct `sep_mark` values for a range of locales + expect_equal( + c( + get_locale_sep_mark(locale = "fr_CF", default = ",", use_seps = TRUE), + get_locale_sep_mark(locale = "en_JE", default = ",", use_seps = TRUE), + get_locale_sep_mark(locale = "en_KY", default = ",", use_seps = TRUE), + get_locale_sep_mark(locale = "ln_CF", default = ",", use_seps = TRUE), + get_locale_sep_mark(locale = "en_MO", default = ",", use_seps = TRUE), + get_locale_sep_mark(locale = "teo_UG", default = ",", use_seps = TRUE), + get_locale_sep_mark(locale = "en_IL", default = ",", use_seps = TRUE), + get_locale_sep_mark(locale = "pt_PT", default = ",", use_seps = TRUE), + get_locale_sep_mark(locale = "en_DE", default = ",", use_seps = TRUE) + ), + c(" ", ",", ",", ".", ",", ",", ",", " ", ".") + ) +}) + +test_that("the `get_locale_dec_mark()` function works correctly", { + + # Expect that a `locale` which is `NULL` will return the + # default value + expect_equal( + c( + get_locale_dec_mark(locale = NULL, default = "."), + get_locale_dec_mark(locale = NULL, default = ","), + get_locale_dec_mark(locale = NULL, default = " ") + ), + c(".", ",", " ") + ) + + # Expect that an invalid `locale` will result in + # an error + expect_error( + get_locale_dec_mark(locale = "do_IT", default = ".") + ) + + # Expect the correct `dec_mark` values for a range of locales + expect_equal( + c( + get_locale_dec_mark(locale = "fr_CF", default = "."), + get_locale_dec_mark(locale = "en_JE", default = "."), + get_locale_dec_mark(locale = "en_KY", default = "."), + get_locale_dec_mark(locale = "ln_CF", default = "."), + get_locale_dec_mark(locale = "en_MO", default = "."), + get_locale_dec_mark(locale = "teo_UG", default = "."), + get_locale_dec_mark(locale = "en_IL", default = "."), + get_locale_dec_mark(locale = "pt_PT", default = "."), + get_locale_dec_mark(locale = "en_DE", default = ".") + ), + c(",", ".", ".", ",", ".", ".", ".", ",", ",") + ) +}) + +test_that("the `has_order_zero()` function works correctly", { + + # Create numeric vectors, with and without + # NA values + x <- c(-500, -50, -5, -0.5, -0.05, 0, 0.05, 0.5, 5, 50, 500) + x_has_NA <- c(NA_real_, -50, -5, -0.5, -0.05, 0, 0.05, 0.5, 5, 50, NA_real_) + + # Expect that a vector of numbers introduced + # to `has_order_zero()` will result in a equal- + # length logical vector (for vectors that have + # and don't have NA values) + expect_length( + x %>% has_order_zero(), + length(x) + ) + + expect_length( + x_has_NA %>% has_order_zero(), + length(x_has_NA) + ) + + expect_type( + x %>% has_order_zero(), + "logical" + ) + + expect_type( + x_has_NA %>% has_order_zero(), + "logical" + ) + + # Expect the correct logical values for + # vectors that have and don't have NA values + expect_equal( + x %>% has_order_zero(), + x_has_NA %>% has_order_zero(), + c(FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, + FALSE, FALSE, TRUE, FALSE, FALSE) + ) +}) + +test_that("the `split_string_2()` function works correctly", { + + test_str <- "-HK$4,299" + + # Expect certain length 2 character vectors from a series + # of `split_string_2()` operations with regex matching + expect_equal(split_string_2(x = test_str, before = "HK"), c("-", "HK$4,299")) + expect_equal(split_string_2(x = test_str, after = "HK"), c("-HK", "$4,299")) + expect_equal(split_string_2(x = test_str, before = "\\$"), c("-HK", "$4,299")) + expect_equal(split_string_2(x = test_str, after = "\\$"), c("-HK$", "4,299")) + expect_equal(split_string_2(x = test_str, before = "9"), c("-HK$4,2", "99")) + expect_equal(split_string_2(x = test_str, after = "9"), c("-HK$4,29", "9")) + expect_equal(split_string_2(x = test_str, before = "99"), c("-HK$4,2", "99")) + expect_equal(split_string_2(x = test_str, after = "99"), c("-HK$4,299", "")) + expect_equal(split_string_2(x = test_str, before = "9"), c("-HK$4,2", "99")) + expect_equal(split_string_2(x = test_str, before = "$"), c("-HK$4,299", "")) + expect_equal(split_string_2(x = test_str, after = "$"), c("-HK$4,299", "")) + expect_equal(split_string_2(x = test_str, before = ".$"), c("-HK$4,29", "9")) + expect_equal(split_string_2(x = test_str, after = ".$"), c("-HK$4,299", "")) + expect_equal(split_string_2(x = test_str, before = "^."), c("", "-HK$4,299")) + expect_equal(split_string_2(x = test_str, after = "^."), c("-", "HK$4,299")) + expect_equal(split_string_2(x = test_str, before = "x"), c("-HK$4,299", "")) + expect_equal(split_string_2(x = test_str, after = "x"), c("-HK$4,299", "")) + + # Expect certain length 2 character vectors from a series + # of `split_string_2()` operations with numeric positions + expect_equal(split_string_2(x = test_str, before = 0), c("", "-HK$4,299")) + expect_equal(split_string_2(x = test_str, before = 1), c("", "-HK$4,299")) + expect_equal(split_string_2(x = test_str, before = 2), c("-", "HK$4,299")) + expect_equal(split_string_2(x = test_str, before = 3), c("-H", "K$4,299")) + expect_equal(split_string_2(x = test_str, before = 4), c("-HK", "$4,299")) + expect_equal(split_string_2(x = test_str, before = 5), c("-HK$", "4,299")) + expect_equal(split_string_2(x = test_str, before = 6), c("-HK$4", ",299")) + expect_equal(split_string_2(x = test_str, before = 7), c("-HK$4,", "299")) + expect_equal(split_string_2(x = test_str, before = 8), c("-HK$4,2", "99")) + expect_equal(split_string_2(x = test_str, before = 9), c("-HK$4,29", "9")) + expect_equal(split_string_2(x = test_str, after = 0), c("", "-HK$4,299")) + expect_equal(split_string_2(x = test_str, after = 1), c("-", "HK$4,299")) + expect_equal(split_string_2(x = test_str, after = 2), c("-H", "K$4,299")) + expect_equal(split_string_2(x = test_str, after = 3), c("-HK", "$4,299")) + expect_equal(split_string_2(x = test_str, after = 4), c("-HK$", "4,299")) + expect_equal(split_string_2(x = test_str, after = 5), c("-HK$4", ",299")) + expect_equal(split_string_2(x = test_str, after = 6), c("-HK$4,", "299")) + expect_equal(split_string_2(x = test_str, after = 7), c("-HK$4,2", "99")) + expect_equal(split_string_2(x = test_str, after = 8), c("-HK$4,29", "9")) + expect_equal(split_string_2(x = test_str, after = 9), c("-HK$4,299", "")) + + # Expect an error if `x` is not of class character + expect_error(split_string_2(x = 23432, before = "34")) + + # Expect an error if the length of `x` is not 1 + expect_error(split_string_2(x = c("345", "234"), before = "34")) + + # Expect an error if neither of `before` or `after` has a value + expect_error(split_string_2(x = "23432")) + + # Expect an error if both `before` and `after` have values + expect_error(split_string_2(x = "23432", before = "3", after = "2")) + + # Expect an error if the index position is not valid + expect_error(split_string_2(x = "23432", before = 10)) +}) + +test_that("the `paste_between()` function works correctly", { + + # Expect a correctly formed string with `paste_between()` + expect_equal( + paste_between(x_2 = c("left", "right"), "-between-"), + "left-between-right" + ) + + # Expect multiple correctly formed strings with `paste_between()` + expect_equal( + paste_between(x_2 = c("left", "right"), c("-a-", "-b-", "-c-")), + c("left-a-right", "left-b-right", "left-c-right") + ) + + # Expect an error if the class of `x_2` is not `character` + expect_error(paste_between(x_2 = 1:2, "-between-")) + + # Expect an error if the class of `x_between` is not `character` + expect_error(paste_between(x_2 = c("left", "right"), 1)) + + # Expect an error if the length of `x_2` is not 2 + expect_error(paste_between(x_2 = "left", "between")) +}) + +test_that("the `paste_on_side()` function works correctly", { + + # Expect a correctly formed string with `paste_on_side()`, + # pasting to the left + expect_equal( + paste_on_side(x = "center", x_side = "left-", direction = "left"), + "left-center" + ) + + # Expect a correctly formed string with `paste_on_side()`, + # pasting to the right + expect_equal( + paste_on_side(x = "center", x_side = "-right", direction = "right"), + "center-right" + ) + + # Expect an error if `direction` is not valid + expect_error(paste_on_side(x = "center", x_side = "c", direction = "center")) +}) + +test_that("the `paste_left()` function works correctly", { + + # Expect correctly formed strings with `paste_left()` + expect_equal( + paste_left(x = "center", "left-"), + "left-center" + ) + expect_equal( + paste_left(x = c("a", "b", "c"), "left-"), + c("left-a", "left-b", "left-c") + ) + expect_equal( + paste_left(x = c("c1", "c2", "c3"), c("l1-", "l2-", "l3-")), + c("l1-c1", "l2-c2", "l3-c3") + ) + + # Expect an error if the class of `x` is not `character` + expect_error(paste_left(x = 1, x_left = "left")) + + # Expect an error if the class of `x_left` is not `character` + expect_error(paste_left(x = "center", x_left = 1)) + + # Expect an error if the length of `x_left` is not 1 of the length of `x` + expect_error(paste_left(x = "center", x_left = c("l1", "l2", "l3"))) + expect_error(paste_left(x = c("c1", "c2", "c3"), x_left = c("l1", "l2"))) +}) + +test_that("the `paste_right()` function works correctly", { + + # Expect correctly formed strings with `paste_right()` + expect_equal( + paste_right(x = "center", "-right"), + "center-right" + ) + expect_equal( + paste_right(x = c("a", "b", "c"), "-right"), + c("a-right", "b-right", "c-right") + ) + expect_equal( + paste_right(x = c("c1", "c2", "c3"), c("-r1", "-r2", "-r3")), + c("c1-r1", "c2-r2", "c3-r3") + ) + + # Expect an error if the class of `x` is not `character` + expect_error(paste_right(x = 1, x_right = "right")) + + # Expect an error if the class of `x_right` is not `character` + expect_error(paste_right(x = "center", x_right = 1)) + + # Expect an error if the length of `x_right` is not 1 of the length of `x` + expect_error(paste_left(x = "center", x_right = c("r1", "r2", "r3"))) + expect_error(paste_left(x = c("c1", "c2", "c3"), x_right = c("r1", "r2"))) +}) diff --git a/vignettes/gt-datasets.Rmd b/vignettes/gt-datasets.Rmd index fa79d8c73b..5e74a79334 100644 --- a/vignettes/gt-datasets.Rmd +++ b/vignettes/gt-datasets.Rmd @@ -459,7 +459,7 @@ pizzaplace %>% ) %>% tab_options( summary_row.background.color = "#ACEACE", - stub_group.background.color = "#FFEFDB" + row_group.background.color = "#FFEFDB" ) ``` @@ -531,10 +531,7 @@ exibble %>% tab_options( column_labels.font.size = "small", table.font.size = "small", - stub_group.font.size = "small", + row_group.font.size = "small", row.padding = px(3) ) ``` - - - diff --git a/vignettes/intro-creating-gt-tables.Rmd b/vignettes/intro-creating-gt-tables.Rmd index 2b23f15cf8..8e946aa958 100644 --- a/vignettes/intro-creating-gt-tables.Rmd +++ b/vignettes/intro-creating-gt-tables.Rmd @@ -31,7 +31,7 @@ Let's use a less common dataset that is available in the R **datasets** package: # dplyr functionality to obtain the ten # biggest islands in the world islands_tbl <- - dplyr::data_frame( + dplyr::tibble( name = names(islands), size = islands ) %>%