Rank2NumVar: Comparing the biggest units with respect to two numerical...

Rank2NumVarR Documentation

Comparing the biggest units with respect to two numerical variables

Description

Calculating rank and share for two numerical variables, and the ratio between the variables Listing big units, either the k biggest units or units with value greater than a threshold

Usage

Rank2NumVar(
  data,
  idVar,
  xVar,
  yVar,
  strataVar = NULL,
  antall = 5,
  grense = NULL,
  identiske = FALSE
)

Arguments

data

Input data set of class data.frame.

idVar

Name of an identification variable.

xVar

Name of the x variable to be compared.

yVar

Name of the y variable to be compared.

strataVar

Name of stratification variable. Optional. If strataVar is given, the calculation and listing is performed within each stratum.

antall

Parameter specifying how many of the biggest units to be listed. Default 5.

grense

Parameter specifying a threshold for the units to be listed. This parameter overrules antall. Optional.

identiske

When TRUE, only units with value on both x and y are used in the calculations. Default FALSE.

Value

Output of Rank2NumVar is a data set of class data.frame. The variables in the data frame are:

id

The input identification variable

x

The input x variable

y

The input y variable

strata

The input strata variable if strataVar is given, "1" otherwise

forh

The ratio between x and y: y/x

xRank

The rank of x

yRank

The rank of y

xProsAvSumx

x in percent of the total/stratum total for x

yProsAvSumy

y in percent of the total/stratum total for y

Author(s)

Anna Mevik

Examples

testdata <- KostraData("testdata")

# lager en grupperingsvariabel
testdata$gr <- as.character(c(rep(3, 30), rep(5, 40), rep(1, 61), rep(2, 91), rep(3, 68),
                              rep(4, 61), rep(5, 45),  rep(4, 20)))

# uten strata
Rank2NumVar(data = testdata, idVar = "Region", xVar = "areal_130_eier_2014", yVar = "areal_130_eier_2015",
            strataVar = NULL, antall = 10, grense = NULL, identiske = FALSE)

# med strata
Rank2NumVar(data = testdata, idVar = "Region", xVar = "areal_130_eier_2014", yVar = "areal_130_eier_2015",
            strataVar = "gr", antall = 10, grense = NULL, identiske = FALSE)

# med identiske = TRUE
Rank2NumVar(data = testdata, idVar = "Region", xVar = "areal_130_eier_2014", yVar = "areal_130_eier_2015",
            strataVar = "gr", antall = 10, grense = NULL, identiske = TRUE)

# med grense (overstyrer antall)
Rank2NumVar(data = testdata, idVar = "Region", xVar = "areal_130_eier_2014", yVar = "areal_130_eier_2015",
            strataVar = "gr", antall = 10, grense = 10000, identiske = FALSE)


statisticsnorway/Kostra documentation built on Nov. 2, 2024, 6:40 p.m.