widenames: Generate Names for a Wide Stuctured Dataset

Description Usage Arguments See Also Examples

Description

This function attempts to be flexible, but may not cover all usage cases. See the examples for known-supported usage cases.

Usage

1
widenames(varnames, varlevels = vector("list", length(varnames)))

Arguments

varnames

This can be a vector of character values, a list of character values, or a data.frame of factors.

varlevels

This can be a vector of numeric (specifying the number of levels) or a list of character (specifying the factor levels) when varnames is a vector of characters. When varnames is a data.frame, it must be a list specifying either the numeric id of the desired factor levels or the names of the factors themselves.

See Also

longframe

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
widenames(c("Age","Workload"),c(2,2))
widenames(c("Age","Workload"),list(c("Young","Old"),c("High","Low")))
widenames(list("Age","Workload"),list(c("Young","Old"),c("High","Low")))
widenames(list("Age","Workload"),c(2,2))

df <- data.frame(Var1=factor(LETTERS[1:5]),Var2=factor(10:14))
widenames(df)
widenames(df,list(Var1=c("A","B"),Var2=1:2))
widenames(df,list(Var1=c("A","B"),Var2=NULL))
widenames(df,list(Var1=NULL,Var2=1:2))
widenames(df,list(Var1=NULL,Var2=c("11","13")))
widenames(df,list(Var1=c("A","B"),Var2=c("10","11","12")))
# widenames(df,c(2,3)) #Not supported
data(examples213)
widenames(sec213.1.I.L[c("Prep","Day")])

drknexus/repsych documentation built on May 15, 2019, 2:19 p.m.