plot_summary | R Documentation |
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.
plot_summary(pt, id_var, type = NULL, group_var = NULL)
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". |
A ggplot2 graphical object
### --- 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.