[R] vertically concatenating data frames

Greg Snow Greg.Snow at intermountainmail.org
Tue Jul 3 20:06:36 CEST 2007


Use rbind instead of c:

> df <- rbind(df1,df2)

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
 
 

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of 
> Aydemir, Zava (FID)
> Sent: Tuesday, July 03, 2007 12:01 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] vertically concatenating data frames
> 
> Hi,
>  
> what is the recommended way to vertically concatenate 2 data 
> frames with the same column names but different number of rows?
>  
> My problem is something along these lines:
>  
> df1 <- data.frame(var1=var1,var2=var2,var3=var3)  # nrow(df1)=1000
> df2 <- data.frame(var1=var4,var2=var5,var3=var6)  # nrow(df2)=2000
>  
> I tried df <- c(df1,df2), no success. stack does not seem to 
> be appropriate either for my problem.
>  
>  
> Thanks
>  
> Zava
> --------------------------------------------------------
> 
> This is not an offer (or solicitation of an offer) to 
> buy/se...{{dropped}}
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list