I wish to create a data.frame with two columns, and each column contains multiple columns. (I need it to feed plsr in the pls package)
It's like the oliveoil data.
> oliveoil
chemical.Acidity chemical.Peroxide chemical.K232 chemical.K270 chemical.DK sensory.yellow sensory.green
G1 0.7300 12.7000 1.9000 0.1390 0.0030 21.4 73.4
G2 0.1900 12.3000 1.6780 0.1160 -0.0040 23.4 66.3
G3 0.2600 10.3000 1.6290 0.1160 -0.0050 32.7 53.5
G4 0.6700 13.7000 1.7010 0.1680 -0.0020 30.2 58.3
G5 0.5200 11.2000 1.5390 0.1190 -0.0010 51.8 32.5
I1 0.2600 18.7000 2.1170 0.1420 0.0010 40.7 42.9
I2 0.2400 15.3000 1.8910 0.1160 0.0000 53.8 30.4
I3 0.3000 18.5000 1.9080 0.1250 0.0010 26.4 66.5
I4 0.3500 15.6000 1.8240 0.1040 0.0000 65.7 12.1
I5 0.1900 19.4000 2.2220 0.1580 -0.0030 45.0 31.9
S1 0.1500 10.5000 1.5220 0.1160 -0.0040 70.9 12.2
S2 0.1600 8.1400 1.5270 0.1063 -0.0020 73.5 9.7
S3 0.2700 12.5000 1.5550 0.0930 -0.0020 68.1 12.0
S4 0.1600 11.0000 1.5730 0.0940 -0.0030 67.6 13.9
S5 0.2400 10.8000 1.3310 0.0850 -0.0030 71.4 10.6
S6 0.3000 11.4000 1.4150 0.0930 -0.0040 71.4 10.0
sensory.brown sensory.glossy sensory.transp sensory.syrup
G1 10.1 79.7 75.2 50.3
G2 9.8 77.8 68.7 51.7
G3 8.7 82.3 83.2 45.4
G4 12.2 81.1 77.1 47.8
G5 8.0 72.4 65.3 46.5
I1 20.1 67.7 63.5 52.2
I2 11.5 77.8 77.3 45.2
I3 14.2 78.7 74.6 51.8
I4 10.3 81.6 79.6 48.3
I5 28.4 75.7 72.9 52.8
S1 10.8 87.7 88.1 44.5
S2 8.3 89.9 89.7 42.3
S3 10.8 78.4 75.1 46.4
S4 11.9 84.6 83.8 48.5
S5 10.8 88.1 88.5 46.7
S6 11.4 89.5 88.5 47.2
And it is a data.frame with 2 columns:
> is.data.frame(oliveoil)
[1] TRUE
> dim(oliveoil)
[1] 16 2
I tried the following code:
x = data.frame(a = c(1,2,3), b = c(1,3,4))
y = data.frame(c = c(3,4,5), d = c(5,4,2))
d = data.frame(x = x, y = y)
it returns:
> d
x.a x.b y.c y.d
1 1 1 3 5
2 2 3 4 4
3 3 4 5 2
but I cannot call x with d$x
> d$x
NULL
what I expect is:
> d$x
a b
1 1 1
2 2 3
3 3 4
I am expecting some arguments in the data.frame function make it work, something like:
d = data.frame(x = x, y = y, merge.columns = F)
But I cannot find any arguments doing this in the docs