我有data_VOC_A和data_VOC_B是小时数据集,但是它们是不规则的,所以当我合并两个数据集时,我想填充空白单元格NA。
#data frames
data_VOC_A <-structure(list(Date = structure(1:2, .Label = c("09.09.2011 21:54",
"09.09.2011 22:59"), class = "factor"), hexane = c(0, 0), benzene = structure(1:2, .Label = c("0",
"4.4"), class = "factor"), toluene = c(2.2, 2.6)), .Names = c("Date",
"hexane", "benzene", "toluene"), row.names = 1:2, class = "data.frame")
data_VOC_B<-structure(list(Date = structure(1:2, .Label = c("09.09.2011 21:54",
"09.09.2011 22:59"), class = "factor"), ethane = c(14.4, 868.9
), propane = c(6.4, 32.1), isobutane = c(1.7, 2), n.butane = c(3.1,
3), isopentane = c(5.6, 3), n.pentane = c(1.4, 2.4)), .Names = c("Date",
"ethane", "propane", "isobutane", "n.butane", "isopentane", "n.pentane"
), row.names = 1:2, class = "data.frame")
#merge data frames
d2<- merge.data.frame(data_VOC_A,data_VOC_B, by='Date', all=TRUE)
合并数据框(d2)的时间轴存在问题。