LAPOP Stacked Bar Graph Pre-Processing
lpr_stack.Rd
This function creates dataframes which can then be input in lapop_stack() for plotting variables categories with a stacked bar graph using LAPOP formatting.
Usage
lpr_stack(
data,
outcome,
xvar = NULL,
sort = "y",
order = "hi-lo",
filesave = "",
keep_nr = FALSE
)
Arguments
- data
The data that should be analyzed. It requires a survey object from lpr_data() function.
- outcome
Vector of variables be plotted.
- xvar
Character. Outcome variable will be broken down by this variable. Default is NULL
- sort
Character. On what value the bars are sorted: the x or the y. Options are "y" (default; for the value of the outcome variable), "xv" (for the underlying values of the x variable), "xl" (for the labels of the x variable, i.e., alphabetical).
- order
Character. How the bars should be sorted. Options are "hi-lo" (default) or "lo-hi".
- filesave
Character. Path and file name to save the dataframe as csv.
- keep_nr
Logical. If TRUE, will convert "don't know" (missing code .a) and "no response" (missing code .b) into valid data (value = 99) and use them in the denominator when calculating percentages. The default is to examine valid responses only. Default: FALSE.
Author
Robert Vidigal, robert.vidigal@vanderbilt.edu
Examples
if (FALSE) lpr_stack(data = gm, outcome = c("countfair1", "countfair3")) # \dontrun{}
if (FALSE) lpr_stack(data = gm, outcome = "pese1", xvar="year") # \dontrun{}