r - Combine two data frames of the same size one column after each other -
i have 2 datasets both of same size [132,450000]. 1 values , p-values corresponding values. want combine 2 datasets have 1 large dataframe [264,450000] column values followed column corresponding p-values. rownames same , column names like: sample1 in df1 , sample1_pval in df2
for example have 2 dataframes likes this
> df1 x y cg1 1 cg2 2 b cg3 3 c cg4 4 d cg5 5 e > df2 x_pval y_pval cg1 6 f cg2 7 g cg3 8 h cg4 9 cg5 10 j
and want merge them order: 1st column of df1 followed 1st column of df2 followed 2nd column of df1 followed 2nd column of df2 etc etc.....
so this:
> df x x_pval y y_pval cg1 1 6 f cg2 2 7 b g cg3 3 8 c h cg4 4 9 d cg5 5 10 e j
i want keep columnnames rownames can add later since same in both dataframes. since i'm working large dataset dont want type in columns , use "cbind". , couldn't find code "merge" 1 column each dataset @ time......
is there formula or package this?
anyone can me out?
another option concatenate sequence of columns of both datasets, order
, cbind
cbind(df1, df2)[order(c(seq_along(df1), seq_along(df2)))] # x x_pval y y_pval #cg1 1 6 f #cg2 2 7 b g #cg3 3 8 c h #cg4 4 9 d #cg5 5 10 e j
Comments
Post a Comment