Learn R Programming

genvar (version 0.0.1.4)

varlist: creates a formula object from a varlist, mostly for internal use.

Description

A varlist in genvar is either a space-separated string with wildcard characters, "var1 var2 var3 x*", or an R formula object ~var1+var2+var3+x1+x2.... This function converts from the more user-friendly space-separated string format to the formula format or to a vector of strings.

Usage

varlist(x, type = "formula")

Arguments

x

the varlist to be converted in "var1 var2 var3" format. Can be specified using the globbing characters "*" (match zero or more of any character) or "?" (match any single character) like "var*" or "var?" for "var1 var2 var3" or using regular expressions if regex=TRUE ("var[0-9]+" = "var1 var2 var3").

type

if "formula", return a varlist in formula format; if "vector", return a varlist in character vector format.

Value

a formula object which can be passed to model.frame or a character vector giving the name of each variable