R add rows from colum in 1 table to the bottom of a column in a different table -
i have table (a) columns a1 , a2. have numeric values. want take column a1 , a2 table(b) , place them @ bottom of table(a) in columns a1 , a2. basically, have 2 datasets in different tables , want combine them 1 can analysis. appreciated!
let's have table 1 column , 3 rows: 1,2,3. have table b 1 column , 3 rows: 4,5,6. want output 1 column 6 rows: 1,2,3,4,5,6
this literally rbind() - 2 matrices or data.frames same columns can bound second object passed being bound new rows first. won't work vectors unless turn them matrices.
a = data.frame(a1=c(1,2,3),a2=c("a","b","c")) b = data.frame(a1=c(4,5,6),a2=c("d","e","f")) ab = rbind(a,b) ab # a1 a2 #1 1 #2 2 b #3 3 c #4 4 d #5 5 e #6 6 f = data.frame(a1=c(1,2,3)) b = data.frame(a1=c(4,5,6)) ab = rbind(a,b) ab # a1 #1 1 #2 2 #3 3 #4 4 #5 5 #6 6 = matrix(c(1,2,3),ncol=1) b = matrix(c(4,5,6),ncol=1) ab = rbind(a,b) ab # [,1] #[1,] 1 #[2,] 2 #[3,] 3 #[4,] 4 #[5,] 5 #[6,] 6
Comments
Post a Comment