2

I have n number of dataframes that contain different density values corresponding to different years. I am trying to combine these into one dataframe where all the years from each individual dataframe are contained, with missing values as NA.

I have attempted for loops with merge, and join, with no success. I am still relatively new to r so I may have missed a simple answer.

Here is some example data:

df <- 1920:1930
rand <- sample(100, size = 11, replace = TRUE)
core1 <- cbind(df,rand)
colnames(core1) <- c("Year", "Density")

df2 <- 1924:1937
rand2 <- sample(100, size = 14, replace = TRUE)
core2 <- cbind(df2,rand2)
colnames(core2) <- c("Year", "Density")

df3 <- 1937:1945
rand3 <- sample(100, size = 9, replace = TRUE)
core3 <- cbind(df3,rand3)
colnames(core3) <- c("Year", "Density")
rm(df,df2,df3,rand,rand2,rand3)
Darren468
  • 41
  • 1
  • 6

0 Answers0