# Example data frame
monitor_df <- NULL |> monitor_start("Generate data frame", "Preparation")
my_data <- dummy_data(1000)
# Formats
monitor_df <- monitor_df |> monitor_next("Create formats", "Preparation")
age. <- discrete_format(
"Total" = 0:100,
"under 18" = 0:17,
"18 to under 25" = 18:24,
"25 to under 55" = 25:54,
"55 to under 65" = 55:65,
"65 and older" = 65:100)
sex. <- discrete_format(
"Total" = 1:2,
"Male" = 1,
"Female" = 2)
# Evaluations
monitor_df <- monitor_df |> monitor_next("Nested summarise", "Summarise")
all_nested <- my_data |>
summarise_plus(class = c(year, sex, age),
values = income,
statistics = c("sum", "pct_group", "pct_total", "sum_wgt", "freq"),
formats = list(sex = "sex.", age = "age."),
weight = weight,
nesting = "deepest",
na.rm = TRUE)
monitor_df <- monitor_df |> monitor_next("All summarise", "Summarise")
all_possible <- my_data |>
summarise_plus(class = c(year, sex, age),
values = c(probability),
statistics = c("sum", "p1", "p99", "min", "max", "freq", "freq_g0"),
formats = list(sex = "sex.",
age = "age."),
weight = weight,
nesting = "all",
na.rm = TRUE)
monitor_df <- monitor_df |> monitor_end()
# For detailed plot
monitor_df |> monitor_plot()
# For summarised plot
monitor_df |> monitor_plot(by = "group")
# NOTE: The more complex functions in this package have a detailed monitoring
# integrated which can be viewed by setting the argument 'monitor' to TRUE.
Run the code above in your browser using DataLab