合并循环中的数据,维护日期

时间:2015-09-04 12:56:28

标签: r merge dataframe

我有n个数据帧,其中包含与不同年份对应的不同密度值。我试图将这些组合成一个数据帧,其中包含每个单独数据帧的所有年份,缺少值为NA。

我尝试过使用merge和join的循环,但没有成功。我还是比较新的,所以我可能错过了一个简单的答案。

以下是一些示例数据:

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)

0 个答案:

没有答案