r - How do I move a row in one data frame to a column in another data frame? -
i trying move row in 1 data frame add make new column in data frame. have frame d1:
x y 1 vbr 33333 2 vea 33333 3 vtv 33333
and frame sh:
vbr vea vtv 2014-02-04 360.9457 875.3501 469.1532
sh started out zoo class have tried converting both frames matrix or data frame , using merge , nothing seems work.
when try merge (d1, shares) get:
x y vbr vea vtv 1 vbr 33333 360.9457 875.3501 469.1532 2 vea 33333 360.9457 875.3501 469.1532 3 vtv 33333 360.9457 875.3501 469.1532
what want is:
1 vbr 33333 360.9457 2 vea 33333 875.3501 3 vtv 33333 469.1532
how do this?
try:
cbind(d1, t(sh))
this should work you.
cbind()
combines data.frames
column , t()
transposes sh
1 row , 3 columns 3 rows , 1 column.
Comments
Post a Comment