The transition from a metadata-rich dataframe consisting of projectable_cols to an ordinary dataframe that is fit for presentation is guided by the shadow attributes attached to each column of the initial dataframe. The prj_shadow() function is designed to make it easy to specify those shadow attributes for multiple columns at once.

prj_shadow(.data, ..., .shadow)

Arguments

.data

A dataframe, ideally one containing projectabel_cols

...

tidy-select One or more unquoted expressions separated by commas. Variable names can be used as if they were positions in the data frame, so expressions like x:y can be used to select a range of variables.

.shadow

A character vector containing glue-like specifications to which to set the shadow attribute of the relevant columns.

Value

A dataframe, the columns of which have updated shadow attributes.

Examples

# Create a table made up of `projectable_col`s
my_tbl <- prj_tbl_rows(
  .data = mtcars,
  Cylinders = cyl,
  Transmission = list(Automatic = am %in% 0, Manual = am %in% 1),
)

my_tbl <- prj_tbl_cols(
  .data = my_tbl,
  `V-Shaped` = col_freq(n = vs %in% 1, N = vs %in% 0:1),
  `Not V-shaped` = col_freq(n = vs %in% 0, N = vs %in% 0:1)
)

my_tbl <- prj_tbl_summarise(.data = my_tbl)

# Update the `shadow` attributes
shadow <- c(Count = "{n}", Proportion = "{signif(p, 2)}")
my_tbl <- prj_shadow(my_tbl, where(is_col_freq), .shadow = shadow)

# Project it back into an ordinary dataframe
prj_project(my_tbl)
#> # A tibble: 5 × 6
#>   row_spanner  rows      `V-Shaped.Count` `V-Shaped.Proportion` `Not V-shaped.…`
#> * <col_row>    <col_row> <glue>           <glue>                <glue>          
#> 1 Cylinders    4         10               0.91                  1               
#> 2 Cylinders    6         4                0.57                  3               
#> 3 Cylinders    8         0                0                     14              
#> 4 Transmission Automatic 7                0.37                  12              
#> 5 Transmission Manual    7                0.54                  6               
#> # … with 1 more variable: `Not V-shaped.Proportion` <glue>