-1

I have a list formed of 10 dataframes named MS1, ..., MS10. Each dataframe has a column 'DateTime' which is a POSIXct and a column 'Depth' (integer value). The dataframes are all of different lengths but all have overlapping DateTimes at some point.

To make simultaneous analysis and plotting of this data easier I would like to have all of these in a single dataframe with one column for DateTime and 10 columns named MS1, ..., MS10 holding the values previously held in the 'Depth' column for each dataframe. I would like to retain all values.

I am aware that there are various functions in R for joining merging dataframes (e.g. merge, rbind, join) but I am unsure which method is the best to do this task?

James
  • 105
  • 2
  • 3
  • 8

1 Answers1

0
df <- df.list[[1]]
for (i in 2:length(df.list)) {
  df <- merge(df, df.list[[i]], by = DateTime, all = TRUE)
}
Dij
  • 1,318
  • 1
  • 7
  • 13