我loess
用来在各个图的测量日期之间插入数据。我想获得每年所有 48 个地块的每日分辨率。以下是我的数据集中的一个示例:
dput(vi.sample)
结构(list = C(2012L,2012L,2012L,2012L,2012L,2012L,2012L,2012L,2012L,2012L,2012L,2012L,2012L,2012L,2012L,2012L,2012L,2012L,2012L,2012L,2012L,2012L,2012L,2012L,2012L,2012L,2012L,2012L 2012L), 朱利安 = c(150L, 153L, 157L, 165L, 173L, 179L, 186L, 193L, 201L, 208L, 226L, 150L, 153L, 157L, 165L, 173L, 179L, 186L, 1908L, 226L, 22, ), jdx = c(2.573770492, 2.625245902, 2.693879781, 2.831147541, 2.968415301, 3.07136612, 3.19147541, 3.311584699, 3.448852459, 3.568961749, 3.877814208, 2.573770492, 2.625245902, 2.693879781, 2.831147541, 2.968415301, 3.07136612, 3.19147541, 3.311584699, 3.448852459, 3.568961749, 3.877814208) , 站点 = 结构 (c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L ), .Label = "east", class = "factor"), type = structure(c(1L, 1L, 1L, 1L, 1L,1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "b", class = "factor"), trt =结构(c(1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L), .Label = "a", class = "factor"), plot = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), vi = c(0.41, 0.44, 0.52, 0.64, 0.66, 0.67, 0.64, 0.66, 0.61, 0.7, 0.7, 0.41, 0.45, 0.55, 0.61, 0.63, 0.6 , 0.63, 0.64, 0.6, 0.7, 0.69)), .Names = c("year", "julian", "jdx", "site", "type", "trt", "plot", "vi") , class = "data.frame", row.names = c(NA, -22L))b", class = "factor"), trt = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "a", class = "factor"), plot = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L , 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), vi = c(0.41, 0.44, 0.52, 0.64, 0.66, 0.67, 0.64, 0.66, 0.61, 0.7, 0.7, 0.41, 0.45, 0.55, 0.61, 0.63, 0.66, 0.63, 0.64, 0.6, 0.7, 0.69)), .Names = c("year", "julian", "jdx", "site", "type", " trt"、"plot"、"vi")、class = "data.frame"、row.names = c(NA, -22L))b", class = "factor"), trt = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "a", class = "factor"), plot = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L , 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), vi = c(0.41, 0.44, 0.52, 0.64, 0.66, 0.67, 0.64, 0.66, 0.61, 0.7, 0.7, 0.41, 0.45, 0.55, 0.61, 0.63, 0.66, 0.63, 0.64, 0.6, 0.7, 0.69)), .Names = c("year", "julian", "jdx", "site", "type", " trt"、"plot"、"vi")、class = "data.frame"、row.names = c(NA, -22L))类=“因子”),绘图= c(1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,2L,2L,2L,2L,2L,2L,2L,2L,2L , 2L, 2L), vi = c(0.41, 0.44, 0.52, 0.64, 0.66, 0.67, 0.64, 0.66, 0.61, 0.7, 0.7, 0.41, 0.45, 0.55, 0.61, 0.63, 0.66, 0.63, 0.64, 0.63, 0.64, 0.7, 0.69)), .Names = c("year", "julian", "jdx", "site", "type", "trt", "plot", "vi"), class = "data.frame ", row.names = c(NA, -22L))类=“因子”),绘图= c(1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,1L,2L,2L,2L,2L,2L,2L,2L,2L,2L , 2L, 2L), vi = c(0.41, 0.44, 0.52, 0.64, 0.66, 0.67, 0.64, 0.66, 0.61, 0.7, 0.7, 0.41, 0.45, 0.55, 0.61, 0.63, 0.66, 0.63, 0.64, 0.63, 0.64, 0.7, 0.69)), .Names = c("year", "julian", "jdx", "site", "type", "trt", "plot", "vi"), class = "data.frame ", row.names = c(NA, -22L))“类型”、“trt”、“绘图”、“vi”)、class = “data.frame”、row.names = c(NA, -22L))“类型”、“trt”、“绘图”、“vi”)、class = “data.frame”、row.names = c(NA, -22L))
我需要在收集的数据的三个季节(2012 - 2014 年)的每一季中插入每个地块的数据。subset
我已经通过使用该功能成功地做到了这一点。请注意,我使用的是朱利安日期,但我并不特别喜欢这种日期格式。
lo <- loess(vi~julian,
subset(vi.sample, year=="2012" & site=="east"
& type=="b" & trt=="a" & plot=="1"),
model=TRUE,
na.action=na.exclude)
问题:有没有一种方法可以自动化代码来插入来自每个情节/年份组合的数据,而不必对每个情节/年份组合进行子集化?我正在考虑nlsList
使用| year/site/type/trt/plot
设计的功能。
我的第二个问题涉及predict
功能。以下代码成功显示了上面指定图的拟合 vi 值。
pred <- predict(lo, seq(from =150, to =226,
by = 1), se=FALSE)
但是,相应的 x 值与原始儒略日期不同。
问题:如何获得预测值来表示黄土模型中使用的儒略日期?请注意,这些日期可能因每年/情节而异。