Tuesday, April 19, 2016

Concatenate Two Data Frames

cbind(df1, df2)

cbind() function combines vector, matrix or data frame by columns.


cbind(x1,x2,...)
x1,x2:vector, matrix, data frames


Read in the data from the file:
>x <- read.csv("data1.csv",header=T,sep=",")
>x2 <- read.csv("data2.csv",header=T,sep=",")

>x3 <- cbind(x,x2)
>x3
  Subtype Gender Expression Age     City
1       A      m      -0.54  32 New York
2       A      f      -0.80  21  Houston
3       B      f      -1.03  34  Seattle
4       C      m      -0.41  67  Houston

No comments:

Post a Comment