% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lpr_cc.R
\name{lpr_cc}
\alias{lpr_cc}
\title{LAPOP Cross-Country Bar Graph Pre-Processing}
\usage{
lpr_cc(
  data,
  outcome,
  xvar = "pais_lab",
  rec = list(c(1, 1)),
  rec2 = list(c(1, 1)),
  rec3 = list(c(1, 1)),
  rec4 = list(c(1, 1)),
  ci_level = 0.95,
  mean = FALSE,
  filesave = "",
  cfmt = "",
  sort = "y",
  order = "hi-lo",
  ttest = FALSE,
  keep_nr = FALSE
)
}
\arguments{
\item{data}{A survey object.  The data that should be analyzed.}

\item{outcome}{Outcome variable(s) of interest to be plotted across countries.
It can handle a single variable across countries, or multiple variables instead of multiple countries. See examples below.}

\item{xvar}{Grouping variable. Default: pais_lab. It can handle other variables grouping like year/wave.}

\item{rec}{Numeric. The minimum and maximum values of the outcome variable that
should be included in the numerator of the percentage.  For example, if the variable
is on a 1-7 scale and rec is c(5, 7), the function will show the percentage who chose
an answer of 5, 6, 7 out of all valid answers.  Default: c(1, 1).}

\item{rec2}{Numeric. Same as rec(). Default: c(1, 1).}

\item{rec3}{Numeric. Same as rec(). Default: c(1, 1).}

\item{rec4}{Numeric. Same as rec(). Default: c(1, 1).}

\item{ci_level}{Numeric. Confidence interval level for estimates.  Default: 0.95}

\item{mean}{Logical.  If TRUE, will produce the mean of the variable rather than
rescaling to percentage.  Default: FALSE.}

\item{filesave}{Character.  Path and file name to save the dataframe as csv.}

\item{cfmt}{changes the format of the numbers displayed above the bars.
Uses sprintf string formatting syntax. Default is whole numbers for percentages
and tenths place for means.}

\item{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).}

\item{order}{Character.  How the bars should be sorted.  Options are "hi-lo"
(default) or "lo-hi".}

\item{ttest}{Logical.  If TRUE, will conduct pairwise t-tests for difference
of means between all individual x levels and save them in attr(x,
"t_test_results"). Default: FALSE.}

\item{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.}
}
\value{
Returns a data frame, with data formatted for visualization by lapop_cc
}
\description{
This function creates dataframes which can then be input in lapop_cc for
comparing values across countries with a bar graph using LAPOP formatting.
}
\examples{

require(lapop); data(ym23); data(bra23)

# Set Survey Context on a small cross-country subset
ym23_small <- subset(ym23, pais \%in\% c(1, 15, 17))
ym23lpr <- lpr_data(ym23_small)

# Single variable in Multiple Countries
lpr_cc(data = ym23lpr,
      outcome = "ing4",
      rec = c(5, 7),
      xvar = "pais")

# Multiple variables in Single Country
\donttest{
bra23lpr <- lpr_data(bra23, wt = TRUE)
lpr_cc(data = bra23lpr,
outcome = c("b12", "b13"),
rec = c(5, 7))
}

}
\author{
Luke Plutowski, \email{luke.plutowski@vanderbilt.edu} & Robert Vidigal, \email{robert.vidigal@vanderbilt.edu}
}
