plot_summary: Plotting of consumption and expenditure

View source: R/plot_summary.R

plot_summaryR Documentation

Plotting of consumption and expenditure

Description

This function helps users to inspect the price-level purchase task data by visualizing the mean and standard error of both consumption and expenditure of either the overall sample or by a grouping variable. For visualization of consumption for each individual, please refer to the 'plot_diagnostics()' function.

Usage

plot_summary(pt, id_var, type = NULL, group_var = NULL)

Arguments

pt

A data frame consisting of the purchase variables for each 'id_var' (and the grouping variable if 'type' equals "group").

id_var

The name of the unique identifier (ID) as found in the data frame.

type

The type of plot to produce. One of c("overall","group"). The "overall" type provides a summary of all individuals in the data frame. The "group" type provides a summary of consumption and expenditure by grouping variable.

group_var

The grouping variable if using type "group".

Value

A ggplot2 graphical object

Examples

### --- Load Data

data("cpt_data")

### --- Prep Data

pt <- price_prep(cpt_data, id_var = "ID", vars = c(paste0("cpt",1:15)),
prices = c("0","0.05","0.10","0.20","0.30","0.40","0.50", "0.75","1","2","3","4","5","7.5","10"))

pt2 <- pt_prep(pt, id_var = "ID", type = "partial", remove0 = TRUE, max_val = 99)
pt3 <- pt_qc(pt2, id_var = "ID", type = "partial")

### --- Function Example

plot_summary(pt3$data, id_var = "ID", type = "overall")


PBCAR/PThelper documentation built on May 13, 2024, 3:45 p.m.