Skip to contents

Helper function to generate template code for a field_types() specification, based on the supplied data frame. All fields (columns) in the specification will be defined using the default_field_type, and the console output can be copied and edited before being used as input to daiquiri_report() or prepare_data().

Usage

template_field_types(df, default_field_type = ft_ignore())

Arguments

df

data frame including the column names for the template specification

default_field_type

field_type to be used for each column. Default = ft_ignore(). See field_types_available()

Value

(invisibly) Character string containing the template code

See also

Examples

df <- data.frame(
  col1 = rep("2022-01-01", 5),
  col2 = rep(1, 5),
  col3 = 1:5,
  col4 = rnorm(5)
)

template_field_types(df, default_field_type = ft_numeric())
#> field_types(
#>   "col1" = ft_numeric(),
#>   "col2" = ft_numeric(),
#>   "col3" = ft_numeric(),
#>   "col4" = ft_numeric()
#> )