Skip to content

Commit

Permalink
Merge pull request #1737 from rstudio/add-fmt-country-example
Browse files Browse the repository at this point in the history
Add `fmt_country()` example
  • Loading branch information
rich-iannone authored Jun 28, 2024
2 parents 694343b + fc9f651 commit 33bdb91
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 25 deletions.
29 changes: 25 additions & 4 deletions R/format_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -12011,6 +12011,27 @@ fmt_flag <- function(
#'
#' @section Examples:
#'
#' The [`peeps`] dataset will be used to generate a small **gt** table
#' containing only the people born in the 1980s. The `country` column contains
#' 3-letter country codes and those will be transformed to country names with
#' `fmt_country()`.
#'
#' ```r
#' peeps |>
#' dplyr::filter(grepl("198", dob)) |>
#' dplyr::select(name_given, name_family, country, dob) |>
#' dplyr::arrange(country, name_family) |>
#' gt() |>
#' fmt_country(columns = country) |>
#' cols_merge(columns = c(name_given, name_family)) |>
#' opt_vertical_padding(scale = 0.5) |>
#' tab_options(column_labels.hidden = TRUE)
#' ```
#'
#' \if{html}{\out{
#' `r man_get_image_tag(file = "man_fmt_country_1.png")`
#' }}
#'
#' Use the [`countrypops`] dataset to create a **gt** table. We will only
#' include a few columns and rows from that table. The `country_code_3` column
#' has 3-letter country codes in the format required for `fmt_country()` and
Expand All @@ -12035,7 +12056,7 @@ fmt_flag <- function(
#' ```
#'
#' \if{html}{\out{
#' `r man_get_image_tag(file = "man_fmt_country_1.png")`
#' `r man_get_image_tag(file = "man_fmt_country_2.png")`
#' }}
#'
#' The country names derived from country codes can be localized. Let's
Expand Down Expand Up @@ -12079,7 +12100,7 @@ fmt_flag <- function(
#' ```
#'
#' \if{html}{\out{
#' `r man_get_image_tag(file = "man_fmt_country_2.png")`
#' `r man_get_image_tag(file = "man_fmt_country_3.png")`
#' }}
#'
#' Let's make another **gt** table, this time using the [`films`] dataset. The
Expand Down Expand Up @@ -12120,7 +12141,7 @@ fmt_flag <- function(
#' ```
#'
#' \if{html}{\out{
#' `r man_get_image_tag(file = "man_fmt_country_3.png")`
#' `r man_get_image_tag(file = "man_fmt_country_4.png")`
#' }}
#'
#' Country names can sometimes pair nicely with flag-based graphics. In this
Expand Down Expand Up @@ -12157,7 +12178,7 @@ fmt_flag <- function(
#' ```
#'
#' \if{html}{\out{
#' `r man_get_image_tag(file = "man_fmt_country_4.png")`
#' `r man_get_image_tag(file = "man_fmt_country_5.png")`
#' }}
#'
#' @family data formatting functions
Expand Down
Binary file modified images/man_fmt_country_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/man_fmt_country_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/man_fmt_country_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/man_fmt_country_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/man_fmt_country_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion man/as_latex.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 24 additions & 16 deletions man/extract_summary.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 24 additions & 4 deletions man/fmt_country.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 33bdb91

Please sign in to comment.