[R] rbind

Petr Pikal petr.pikal at precheza.cz
Thu Apr 6 11:57:27 CEST 2006


Hi

if you are really sure that all columns in all data frames you want 
to stack are the same type and in the same position just make names 
in all data frames equal.

> df1<-data.frame(rnorm(10), rnorm(10))
> df2<-data.frame(rnorm(10), rnorm(10))
> names(df2)<-c("a", "b")
> df1
    rnorm.10. rnorm.10..1
1  -0.1645236   0.3981059
2  -0.2533617  -0.6120264
...
> df2
             a            b
1   2.40161776  0.475509529
2  -0.03924000 -0.709946431
...
> rbind(df1,df2)
Error in match.names(clabs, names(xi)) : names don't match previous 
names:
        a, b

> names(df1)<-names(df2)
> rbind(df1,df2)
              a            b
1   -0.16452360  0.398105880
2   -0.25336168 -0.612026393
3    0.69696338  0.341119691
4    0.55666320 -1.129363096
5   -0.68875569  1.433023702
...

HTH
Petr


On 6 Apr 2006 at 9:46, Mahdi Osman wrote:

Date sent:      	Thu, 6 Apr 2006 09:46:56 +0200 (MEST)
From:           	"Mahdi Osman" <m_osm at gmx.net>
To:             	r-help at stat.math.ethz.ch
Subject:        	[R] rbind

> Hi list,
> 
> I have been trying to pileup dataframes with different column names
> using rbind. I am getting the following error message. I was wondering
> if there is a way to go around this  minor problem?
> 
> Error in match.names(clabs, names(xi)) : names don't match previous
> names:
>  G
> 
> Thanks indeed for your information
> 
> Regards
> 
> Mahdi
> 
> -- 
> -----------------------------------
> Mahdi Osman (PhD)
> E-mail: m_osm at gmx.net
> -----------------------------------
> 
> Echte DSL-Flatrate dauerhaft für 0,- Euro*!
> 
> 

Petr Pikal
petr.pikal at precheza.cz




More information about the R-help mailing list