Diff2NumVar | R Documentation |
Calculating the difference between two numerical variables Listing units with big difference, either the k units with the biggest absolute difference, or units with a absolute difference greater than a threshold Only units with value on both variables are used in the calculations
Diff2NumVar(
data,
idVar,
xVar,
yVar,
strataVar = NULL,
antall = 5,
grense = NULL,
zVar = NULL,
kommentarVar = NULL
)
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 units with the biggest difference to be listed. Default 5. |
grense |
Parameter specifying a threshold for the units to be listed. This parameter overrules antall. Optional. |
zVar |
Name of the original y variable, before editing. Optional. |
kommentarVar |
Name of a variable giving information about the editing. Optional. |
Output of Diff2NumVar is a data set of class data.frame. The variables in the data frame are:
strata |
The stratum (if strataVar is given, "1" otherwise) |
id |
The input identification variable |
x |
The input x variable |
y |
The input y variable |
Forh |
The ratio between x and y: y / x |
Diff |
The difference between x and y: y - x |
AbsDiff |
The absolute difference: |Diff| |
DiffProsAvx |
The difference in percent of x: (Diff / x) * 100 |
DiffProsAvSumx |
The difference in percent of the stratum total for x: (Diff / stratum x) * 100 |
DiffProsAvTotx |
The difference in percent of the total for x: (Diff / total x) * 100 |
SumDiffProsAvSumx |
The stratum difference in percent of the stratum total for x: ((stratum y - stratum x) / stratum x) * 100 |
SumDiffProsAvTotx |
The stratum difference in percent of the total for x: ((stratum y - stratum x) / total x) * 100 |
z |
The input z variable |
EdEndring |
The difference between z and y: y - z |
Kommentar |
The input kommentar variable |
Anna Mevik
testdata <- KostraData("testdata")
# lager en grupperingsvariabel
testdata$gr <- 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))
# lager en z-variabel
testdata$z <- testdata$areal_130_eier_2015
testdata$z[4*(1:104)] <- testdata$areal_130_eier_2014[2*(1:104)]
testdata$z[10*(1:40)] <- 1.2 * testdata$areal_130_eier_2015[10*(1:40)]
testdata$z[10*(1:40) - 5] <- 0.7 * testdata$areal_130_eier_2015[10*(1:40) - 5]
# lager en kommentarvariabel
testdata$kommentar <- ifelse(testdata$areal_130_eier_2015 == testdata$z, "ikke kontrollert",
"godkjent")
testdata$kommentar[c(88)] <- "oppgavegiver kontaktet"
# uten strata
Diff2NumVar(data = testdata, idVar = "Region", xVar = "areal_130_eier_2014", yVar = "areal_130_eier_2015",
strataVar = NULL, antall = 5, grense = NULL, zVar = NULL, kommentarVar = NULL)
# med strata
Diff2NumVar(data = testdata, idVar = "Region", xVar = "areal_130_eier_2014", yVar = "areal_130_eier_2015",
strataVar = "gr", antall = 5, grense = NULL, zVar = NULL, kommentarVar = NULL)
# med z og kommentar
Diff2NumVar(data = testdata, idVar = "Region", xVar = "areal_130_eier_2014", yVar = "areal_130_eier_2015",
strataVar = "gr", antall = 5, grense = NULL, zVar = "z", kommentarVar = "kommentar")
# med grense
Diff2NumVar(data = testdata, idVar = "Region", xVar = "areal_130_eier_2014", yVar = "areal_130_eier_2015",
strataVar = "gr", antall = 5, grense = 5000, zVar = "z", kommentarVar = "kommentar")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.