ud_prep: Prepares data for drawing an UpAndDown plot

Description Usage Arguments Details Value Author(s) Examples

View source: R/ud_prep.R

Description

Checks input parameters and sorts the data

Usage

1
ud_prep(data, weight=1, v1, v2, levs, sortLev, reverse=c(FALSE, FALSE, FALSE))

Arguments

data

the dataset to be analysed

weight

a variable for weighting the individual items, the default is for every item to be weighted equally

v1

the variable specifying the start value in the comparison

v2

the variable specifying the end value in the comparison

levs

up to three grouping variables to define the plot levels in order from highest to lowest

sortLev

how the grouping variables named in levs are to be sorted. Each entry must be one of "orig", "base", "final", "perc", "abs" (i.e., no sorting, sorting by initial value, sorting by final value, sorting by percentage change, sorting by absolute change).

reverse

whether a sorting is to be reversed or not. Each entry must be TRUE or FALSE (the default)and is set separately for each level.

Details

This function draws UpAndDown plots showing percentage and absolute changes for up to three levels. There are a number of options for sorting the data. If a level is nested, then it is sorted within the next highest level. If a level is not nested, then it is sorted as if it were the top level.

Value

levs

the variables specifying the grouping levels for the plot

sortLev

the sorting method used for each plot level

reverse

whether any sortings should be reversed

hx

a summary of the nesting of the grouping variables

lgv

the numbers of categories in the grouping variables

data

an extended version of the dataset comprising the original variables and the derived absolute and percentage changes for the different levels specified in levs. The levels are sorted according to the sortLev settings chosen and the corresponding percentages.

Author(s)

Antony Unwin unwin@math.uni-augsburg.de

Examples

1
2
yy <- ud_prep(CPIuk, weight="Weight", v1="Aug2017", v2="Aug2018",
levs=c("Sector", "Subsector", "Component"), sortLev=c("perc", "perc", "perc"))

heike/UpAndDown documentation built on March 22, 2020, 7:12 p.m.