Revision d4cb3e7e9238e92df8bca607c6f7afd82c8efb52 authored by Daniel Luedecke on 14 August 2014, 18:06:29 UTC, committed by cran-robot on 14 August 2014, 18:06:29 UTC
1 parent 1338a2d
Raw File
sju.groupVarLabels.Rd
% Generated by roxygen2 (4.0.1): do not edit by hand
\name{sju.groupVarLabels}
\alias{sju.groupVarLabels}
\title{Create labels for recoded groups}
\usage{
sju.groupVarLabels(var, groupsize = 5, rightInterval = FALSE,
  autoGroupCount = 30)
}
\arguments{
\item{var}{The scale variable, which should recoded into groups.}

\item{groupsize}{The group-size, i.e. the range for grouping. By default, for each 5 categories
new group is built, i.e. \code{groupsize=5}. Use \code{groupsize="auto"} to automatically
resize a variable into a maximum of 30 groups (which is the ggplot-default grouping when
plotting histograms). Use parameter \code{autoGroupCount} to define the amount of groups.}

\item{rightInterval}{If \code{TRUE}, grouping starts with the lower bound of \code{groupsize}. In this
case, groups cover the ranges from 50-54, 55-59, 60-64 etc. \cr
If \code{FALSE} (default), grouping starts with the upper bound of \code{groupsize}. In this
case, groups cover the ranges from 51-55, 56-60, 61-65 etc.}

\item{autoGroupCount}{Sets the maximum number of groups that are built when auto-grouping is on
         (\code{groupsize="auto"}). Default is 30. If \code{groupsize} is not set to \code{"auto"},
         this parameter will be ignored.}
}
\value{
A string vector containing labels based on the grouped counts of \code{var},
          formatted as "from lower bound to upper bound", e.g. \code{"10-19"  "20-29"  "30-39"} etc.
          See example below.
}
\description{
Creates the related labels for the grouped variable created by
               the \code{\link{sju.groupVar}} function.
}
\note{
Usually you should use the same values for \code{groupsize} and
        \code{rightInterval} as used in the \code{\link{sju.groupVar}} function
        if you want to create labels for the related recoded variable.
}
\examples{
age <- abs(round(rnorm(100, 65, 20)))
age.grp <- sju.groupVar(age, 10)
hist(age)
hist(age.grp)

age.grpvar <- sju.groupVarLabels(age, 10)
table(age.grp)
print(age.grpvar)

# histogram with EUROFAMCARE sample dataset
# variable not grouped
data(efc)
efc.val <- sji.getValueLabels(efc)
efc.var <- sji.getVariableLabels(efc)
sjp.frq(efc$e17age,
        title=efc.var[['e17age']],
        type="h",
        showValueLabels=FALSE)

# bar plot with EUROFAMCARE sample dataset
# grouped variable
data(efc)
efc.val <- sji.getValueLabels(efc)
efc.var <- sji.getVariableLabels(efc)
ageGrp <- sju.groupVar(efc$e17age)
ageGrpLab <- sju.groupVarLabels(efc$e17age)
sjp.frq(ageGrp,
        title=efc.var[['e17age']],
        axisLabels.x=ageGrpLab,
        maxYlim=FALSE)
}
\seealso{
\code{\link{sju.groupVar}}
}

back to top