0

I have a bunch of dataframes, lets say they look like these two:

first <- data_frame(a = sample(letters,10),b = rnorm(10),c = runif(10))
second <- data_frame(f = sample(letters,12),x = rnorm(12),l = runif(12),r = rnorm(12),m = runif(12))

first
# A tibble: 10 x 3
       a           b          c
   <chr>       <dbl>      <dbl>
 1     u  1.15602047 0.17367776
 2     n  0.67501902 0.47188791
 3     w  0.28959362 0.32015586
 4     e -0.05452307 0.60716224
 5     h -0.63011674 0.47321759
 6     m -1.18150210 0.04173023
 7     s  0.07784496 0.06412953
 8     k  0.45639169 0.53202824
 9     z  2.74790520 0.62716438
10     a  0.29259957 0.57580345

> second
# A tibble: 12 x 5
       f          x         l          r          m
   <chr>      <dbl>     <dbl>      <dbl>      <dbl>
 1     y -1.5119402 0.2558284  1.0535754 0.17184873
 2     g -2.3707967 0.1271524  0.1347911 0.24748070
 3     o -0.4106966 0.9878377 -0.4813818 0.45757578
 4     f -1.1347677 0.0459041 -1.3688185 0.91119901
 5     h -1.0625083 0.1654427 -1.0975756 0.55730692
 6     s -0.5025820 0.2638059 -1.1636976 0.74064046
 7     w  1.1237478 0.7906208 -1.9667944 0.54466832
 8     n -1.0375576 0.8213311 -0.8066419 0.90866627
 9     m  0.4517610 0.3252798 -0.3530502 0.95813283
10     z  1.4858616 0.7285661  0.2106819 0.06575591
11     l -0.3757875 0.7362911  0.5443565 0.37027193
12     k -0.8906273 0.4662212  0.6018126 0.79314357

All I need to do is combine all of the headers into a separate dataframe. My desired outcome would look something like this:

> need
# A tibble: 5 x 2
  first second
  <chr>  <chr>
1     a      f
2     b      x
3     c      l
4  <NA>      r
5  <NA>      m

I've tried a whole bunch of permutations of colnames, as_tibble, matrix, unlist, and a few others I can't even remember.

My basic data wrangling skills are about 3 months old, so I need to know where to start looking/researching next. Can anyone help?

Steve
  • 575
  • 4
  • 18
  • 2
    https://stackoverflow.com/questions/19074163/cbind-is-there-a-way-to-have-missing-values-set-to-na – BENY Oct 27 '17 at 21:49
  • thanks wen. seems you're a better StackOverflow researcher than I am! (I never found that Q.) I'll try that approach now. – Steve Oct 27 '17 at 21:51
  • 2
    And https://stackoverflow.com/questions/34570860/adding-na-to-make-all-list-elements-equal-length – Rich Scriven Oct 27 '17 at 21:52

0 Answers0