0

I have a list of 7 data frames (list_df) which I would like to merge into a single data frame (df_tot). The data frames, for the most part, have the same column names - with a couple exceptions - and are comprised mostly of factors with different levels between data frames (see pngs link of structure and head).

I am using the rduce function in purrr as so: df_tot <- reduce(list_df, full_join). However, this causes my pc to crash...

Any help appreciated.

structure

test head

MLavoie
  • 9,671
  • 41
  • 36
  • 56
  • 3
    Do you want to merge these datasets or stack them together? If the latter, see `bind_rows`. – aosmith Aug 02 '17 at 17:58
  • Could you try the same with `test` where `test <- map(list_df, ~head(.x,5))`? – CPak Aug 02 '17 at 18:01
  • I can't use rbind because in a couple datasets the variable differ slightly. – northeastloon Aug 02 '17 at 18:10
  • If that's the only reason you can't use `rbind` (and not, for instance, that it would be the incorrect operation to perform on your data), you can use `dplyr::bind_rows`. Or fix the names of your columns. `rbind` and the like and `full_join` are nowhere near interchangeable. Decide which one is correct for your situation. – Taylor H Aug 02 '17 at 18:29
  • I am assuming full_join is appropriate since some dataframes contain variables (such as 'SUBJECT' and 'INFRASTR') which are not contained in others... – northeastloon Aug 02 '17 at 18:35
  • ok I recalculated by list of dataframes again from scratch and full_join executes (although with multiple warning messages). I'm not sure the reasons for either but will investigate. – northeastloon Aug 02 '17 at 18:41
  • Possible duplicate of [Combine two data frames by rows (rbind) when they have different sets of columns](https://stackoverflow.com/questions/3402371/combine-two-data-frames-by-rows-rbind-when-they-have-different-sets-of-columns) – S Rivero Aug 02 '17 at 18:49

0 Answers0