Here is data:
myd <- data.frame (var1.1 = rnorm (10, 5,2), var1.2 = rnorm (10, 3,1),
varA.1 = rnorm (10, 5,2), varA.2 = rnorm (10,1,2),
C.1 = rnorm (10, 3,1), C.2 = rnorm (10, 4,1))
I want create a list with of size 3 (n/2, if n is number of variable in dataframe) (with two columns each)
mylist <- as.list (myd)
creats a list with each variable as component. But I want create list of pair of variable in one unit – var1.1 and var1.2, similarly varA.1 and varA.2 or C.1 and C.2. Thus new list unit has 2 columns each. Any solution ?
I think this will give you what you want:
Now lets say you wanted to name each element in the list by the shared variable names of the data frame: