View source: R/visualizer-lib-utils.R
list_col_to_chr | R Documentation |
Convert a list-type column (typically in a tibble) to a character-type column. Often useful for plotting along this column.
list_col_to_chr(list_col, name = NULL, verbatim = FALSE)
list_col |
A list-type column to be converted to character. |
name |
Name of column. Used as a prefix in the returned character
strings. Default is |
verbatim |
If |
A character vector of the same length as list_col
.
# create example tibble with list columns to convert
plot_tib <- tibble::tibble(a = 1:3,
b = list(1, 2, 3),
c = list(1:2, 3:4, 5:6),
d = list(tibble::tibble(a = 1:3,
b = c(4, 5, 6)),
"abc",
123))
# verbatim = TRUE pastes lists together verbatim
plot_tib_chr_verbatim <- plot_tib %>%
dplyr::mutate(dplyr::across(tidyselect::everything(),
~list_col_to_chr(.x,
name = dplyr::cur_column(),
verbatim = TRUE)))
# verbatim = FALSE maps items in list to unique ids (i.e., 1, 2, 3, ...)
plot_tib_chr <- plot_tib %>%
dplyr::mutate(dplyr::across(tidyselect::everything(),
~list_col_to_chr(.x,
name = dplyr::cur_column(),
verbatim = FALSE)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.