Skip to content
Prev 298814 / 398503 Next

list to dataframe conversion-testing for identical

On Jul 1, 2012, at 5:09 PM, David L Carlson wrote:

            
Yes, arun. If the coding had proceeded otherwise a more natural and  
expected result might have occurred:

 > dat1<-do.call("data.frame",listdat1)
 > colnames(dat1)<-c("Var1","Var2","Var3")
 > dat1
        Var1 Var2 Var3
1  21.14076    A    1
2  19.53277    B    2
3  19.59725    A    3
4  19.84262    B    4
5  19.93251    A    5
6  20.92242    B    1
7  19.22315    A    2
8  19.13742    B    3
9  18.82441    A    4
10 20.92661    B    5

Whoever taught you to use 'cbind' for construction of data.frames did  
you a great disservice. It would seem much less problematic to have  
simply done this in the first place:

dat1 <- data.frame(Var1=rnorm(10,20),Var2=rep(LETTERS[1:2], 
5),var3=rep(1:5,2) )