Skip to content
Prev 245714 / 398506 Next

data frame with nested data frame

On Dec 23, 2010, at 5:06 PM, Vadim Ogranovich wrote:

            
Speaking as a fellow user, .... why? Why would we want dataframes  
inside dataframes? Why wouldn't lists of dataframes be more  
appropriate if you were hoping to use apply or <some other function> ?
cbind.data.frame  (dispatched if the first argument to cbind is a  
dataframe) would give you another dataframe without the mess of having  
nesting.
 > cbind(z, b=2)
   x b
1 1 2

This is also the time to ask .... what is it that you are _really_  
trying to accomplish?
Yes. the second one is equivalent to passing just the list portions of  
the nameless data.frame and ignoring attributes.
That is a puzzle, I agree.
This succeeds:
z <- data.frame(x=1, y=2)
  rbind(z,z
#########
   x y
1 1 2
2 1 2

Perhaps a bug (... trying to add drop=FALSE had an amusing result:
 > rbind(z,z, drop=FALSE)
      x
1    1
2    1
drop 0

-- 
David