[R] Convetring a dataframe so that it just has one column

Leeds, Mark (IED) Mark.Leeds at morganstanley.com
Tue Jul 3 20:28:47 CEST 2007


I have two dataframes, yendog and datasub as below and I want to do the
same thing to both of them, namely convert
them so that they retain their dataframeness but stack the columns into
1 column. I don't need names
on the results.

I did try 

temp1<-do.call("rbind",datasub)
temp2<-do.call("rbind",yendog)

and also

temp1<-do.call("rbind",lapply(datasub,function(x) { t(x) }))
temp2<-do.call("rbind",lapply(yendog, function(x) { t(x) }))

but neither of them did the trick.  I'm probably making it more
complicated
than it needs to be. Thanks for any sugggestions.


datasub

          AAA.l1        BBB.l1        CCC.l1        DDD.l1        EEE.l1
FFF.l1
2  -1.937171e-04  1.391873e-03  1.713845e-04  2.595525e-04  2.635428e-05
2.047188e-04
3   3.228410e-04  6.047229e-05  1.713551e-04  7.414547e-05 -4.744833e-04
-3.070939e-04
4   0.000000e+00  1.209336e-04 -1.142335e-04 -7.414547e-05 -1.318409e-04
0.000000e+00
5  -1.291239e-04 -4.838222e-04 -6.856751e-04 -2.966369e-04 -7.650202e-04
2.047397e-04
6  -1.937171e-04 -1.814937e-04  0.000000e+00  0.000000e+00 -5.278159e-05
2.046978e-04
7   0.000000e+00 -6.050522e-05  2.286106e-04  5.190568e-04  4.749340e-04
5.115613e-04
8   1.291489e-04  3.629764e-04  4.570645e-04  1.482525e-04  1.582612e-04
2.045513e-04
9  -3.229036e-04 -1.814717e-04 -7.428360e-04 -5.931418e-04 -7.123729e-04
-2.045513e-04
10  8.393325e-04  7.256894e-04  1.714727e-04  3.708167e-05  7.917761e-05
-2.557479e-04
11  6.451613e-04  0.000000e+00  1.142988e-04  2.224612e-04 -2.639497e-04
-4.093328e-04
12  1.934673e-04  0.000000e+00 -1.142988e-04 -3.707342e-05 -5.279831e-05
5.117576e-05
13 -1.096810e-03  3.022152e-04  0.000000e+00 -1.483074e-04 -2.376269e-04
1.023437e-04
14  7.098377e-04 -1.208751e-04  6.855968e-04  3.707274e-04  2.640578e-05
7.672438e-04
16  3.224454e-04  1.087613e-03 -5.712490e-05  2.223870e-04  3.695101e-04
3.066858e-04
17  9.022945e-04  2.171685e-03  6.281945e-04  6.668643e-04  5.803831e-04
4.087681e-04
18 -6.442261e-05 -7.233709e-04  1.712573e-04 -7.407407e-05  1.054880e-04
-1.021764e-04
19 -1.224819e-03 -1.206782e-03 -1.142270e-03 -8.151772e-04 -7.911497e-05
0.000000e+00
20  3.869470e-04 -1.811430e-04 -5.144474e-04 -7.416472e-04  1.318548e-04
-5.621567e-04
21 -1.934548e-04  1.811430e-04  2.858368e-04  1.483735e-04 -7.911079e-05
5.110646e-04
22 -1.934922e-04  6.035732e-04  5.715755e-05 -1.112780e-04  5.274123e-05
-3.066074e-04
23 -7.097919e-04  0.000000e+00  1.714531e-04  1.854565e-04 -1.054852e-04
0.000000e+00
24 -7.748935e-04  1.206709e-04  1.142857e-04  3.708717e-05  1.845919e-04
0.000000e+00
25 -5.815644e-04 -4.827711e-04 -4.000572e-04 -1.112656e-04 -1.054769e-04
1.022129e-04
26 -5.172302e-04  1.207146e-04 -4.574042e-04 -4.080800e-04  1.318444e-04
-3.577909e-04
27  2.586486e-04 -6.641109e-04 -4.004004e-04 -5.196155e-04 -5.273566e-05
5.112082e-05
28  1.292992e-04  1.207802e-04  0.000000e+00  1.856080e-04 -1.582237e-04
5.111821e-05
29  1.292825e-04  0.000000e+00 -5.721315e-05  1.113482e-04  1.582237e-04
-3.578824e-04
30  2.585148e-04 -3.623845e-04  1.716296e-04  3.710713e-04 -2.636887e-05
5.113389e-05


yendog

             AAA           BBB           CCC           DDD           EEE
FFF
2   3.228410e-04  6.047229e-05  1.713551e-04  7.414547e-05 -4.744833e-04
-3.070939e-04
3   0.000000e+00  1.209336e-04 -1.142335e-04 -7.414547e-05 -1.318409e-04
0.000000e+00
4  -1.291239e-04 -4.838222e-04 -6.856751e-04 -2.966369e-04 -7.650202e-04
2.047397e-04
5  -1.937171e-04 -1.814937e-04  0.000000e+00  0.000000e+00 -5.278159e-05
2.046978e-04
6   0.000000e+00 -6.050522e-05  2.286106e-04  5.190568e-04  4.749340e-04
5.115613e-04
7   1.291489e-04  3.629764e-04  4.570645e-04  1.482525e-04  1.582612e-04
2.045513e-04
8  -3.229036e-04 -1.814717e-04 -7.428360e-04 -5.931418e-04 -7.123729e-04
-2.045513e-04
9   8.393325e-04  7.256894e-04  1.714727e-04  3.708167e-05  7.917761e-05
-2.557479e-04
10  6.451613e-04  0.000000e+00  1.142988e-04  2.224612e-04 -2.639497e-04
-4.093328e-04
11  1.934673e-04  0.000000e+00 -1.142988e-04 -3.707342e-05 -5.279831e-05
5.117576e-05
12 -1.096810e-03  3.022152e-04  0.000000e+00 -1.483074e-04 -2.376269e-04
1.023437e-04
13  7.098377e-04 -1.208751e-04  6.855968e-04  3.707274e-04  2.640578e-05
7.672438e-04
14  1.290073e-04 -2.417941e-04 -1.713551e-04 -7.413448e-05  2.640194e-04
1.533782e-04
16  9.022945e-04  2.171685e-03  6.281945e-04  6.668643e-04  5.803831e-04
4.087681e-04
17 -6.442261e-05 -7.233709e-04  1.712573e-04 -7.407407e-05  1.054880e-04
-1.021764e-04
18 -1.224819e-03 -1.206782e-03 -1.142270e-03 -8.151772e-04 -7.911497e-05
0.000000e+00
19  3.869470e-04 -1.811430e-04 -5.144474e-04 -7.416472e-04  1.318548e-04
-5.621567e-04
20 -1.934548e-04  1.811430e-04  2.858368e-04  1.483735e-04 -7.911079e-05
5.110646e-04
21 -1.934922e-04  6.035732e-04  5.715755e-05 -1.112780e-04  5.274123e-05
-3.066074e-04
22 -7.097919e-04  0.000000e+00  1.714531e-04  1.854565e-04 -1.054852e-04
0.000000e+00
23 -7.748935e-04  1.206709e-04  1.142857e-04  3.708717e-05  1.845919e-04
0.000000e+00
24 -5.815644e-04 -4.827711e-04 -4.000572e-04 -1.112656e-04 -1.054769e-04
1.022129e-04
25 -5.172302e-04  1.207146e-04 -4.574042e-04 -4.080800e-04  1.318444e-04
-3.577909e-04
26  2.586486e-04 -6.641109e-04 -4.004004e-04 -5.196155e-04 -5.273566e-05
5.112082e-05
27  1.292992e-04  1.207802e-04  0.000000e+00  1.856080e-04 -1.582237e-04
5.111821e-05
28  1.292825e-04  0.000000e+00 -5.721315e-05  1.113482e-04  1.582237e-04
-3.578824e-04
29  2.585148e-04 -3.623845e-04  1.716296e-04  3.710713e-04 -2.636887e-05
5.113389e-05
30  6.461827e-05  3.623845e-04 -5.720660e-05 -7.420324e-05  1.054713e-04
-2.045513e-04
--------------------------------------------------------

This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}



More information about the R-help mailing list