xpssElseIf: Creates a subcondition within a DO IF - END IF subset

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/xpssElseIf.R

Description

R implementation of the SPSS DO IF argument.

Usage

1
xpssElseIf(x, cond = NULL)

Arguments

x

a (non-empty) data.frame or input data of class "xpssFrame".

cond

logical expression indicating the condition for subsetting.

Details

After using xpssDoIf every following subset command will be initiated by xpssElseIf. xpssElseIf is working similar to xpssDoIf. Both functions select cases for analysis based on one or more logical conditions. The conditions to select cases are specified in a logical expression. These logical expressions can contain relational operators, logical operators and arithmetic operations. xpssElseIf creates a subset of the actual dataset, without deleting the excluded variables, respectively without deleting the excluded values.

The data is subsetted until xpssEndIf restores the excluded data. All changes made at the subsetted data will be taken over, the excluded data will remain untouched! As noted before, those cases are not actually deleted and will be available after xpssEndIf restores the excluded data.

In a different way to SPSS. Not only data management functions like xpssRecode can be used within xpssElseIf, it is possible to use statistical and descriptiv functions like xpssFrequencies too.

NOTE: For temporary case selection, specify xpssTemporary before xpssDoIf.

Value

Output is a subset of the actual dataset under the condition of the logical expression.

Author(s)

Bastian Wiessner

See Also

Related Functions xpssDoIf, xpssEndIf, xpssFilter, xpssSelectIf, xpssTemporary

Examples

1
2
3
4
5
6
data(fromXPSS)
temp <- xpssDoIf(x=fromXPSS, cond = "V3 == 1")
temp <- xpssRecode(x=temp,variables="V5",rec="lo:78 = 1; else = 2")
temp <- xpssElseIf(x=temp, cond = "V3 == 1")
temp <- xpssRecode(x=temp,variables="V5",rec="lo:78 = 11; else = 22")
temp <- xpssEndIf(x=temp)

translateSPSS2R documentation built on May 30, 2017, 4:31 a.m.