varlist {lazy.tools}R Documentation

Interprete sas-like abbreviated variable list

Description

Interprete sas-like abbreviated variable list

Usage

varlist(var = NULL, varlistf = NULL, location = 0, regexpr = NULL)

Arguments

var

string containing sas-like abbreviated variable list such as
"q5-q7 x1 heightgender"
Comma can be a denominator.

varlistf

full list of variables on the basis of which double - is interpreted.
Use varlistf=colnames(data)
This can be NULL when double - is not used.

location

= 1 to output the locatin of var in varlistf
If location == 1, varlistf must be given.

regexpr

a string containing a regular expression to be used to select the variables.
This has priority over var.

Details

varlist( "q2-q5 a cd", varlistf=c("a", "bb","c","d", "e", "gender") )
will return c( "q2", "q3", "q4", "q5", "a", "c", "d" )
When location == 1, in addition to the vector above,
the location of the variable names contained in varlistf, if any, will be output as the 2nd element of the list, which is
c(1,3,4)
Expression such as abc: can be used to designate all the variables whose names start with abc.

Value

vector or list

Examples

varlist( "x3-x1, y5, x8-x9" )
varlistf=c("a", "b","c","d", "e", paste("Q", 1:5, sep=""), "fff" )
varlist( "q2-q5 a e--c", varlistf=varlistf )
varlist( "q2-q5 a e--c Q:", varlistf=varlistf )
varlist( regexpr="^Q[123]", varlistf=varlistf )


[Package lazy.tools version 0.1.3 Index]