我正在尝试在名为vol_coarse
.
install.packages("install.load")
install.load::load_package("pracma", "data.table")
vol_coarse <- data.table(V1 = c(3 / 8, 1 / 2, 3 / 4, 1, 1 + 1 / 2, 2, 3, 6),
V2 = c(0.50, 0.59, 0.66, 0.71, 0.75, 0.78, 0.82, 0.87),
V3 = c(0.48, 0.57, 0.64, 0.69, 0.73, 0.76, 0.80, 0.85),
V4 = c(0.44, 0.53, 0.60, 0.65, 0.69, 0.72, 0.76, 0.81))
setnames(vol_coarse, c("Maximum size of aggregate (in)", "2.40", "2.60", "2.80"))
x <- vol_coarse[, 2][[1]]
y <- as.numeric(colnames(vol_coarse[, 2:ncol(vol_coarse)]))
z <- meshgrid(x, y)
xp <- 3 / 4
yp <- 2.70
interp2(x = x, y = y, Z = z, xp = xp, yp = yp, method = "linear")
这是返回的错误消息:
错误:is.numeric(Z) 不是 TRUE
我读到?interp2
:
length(x) = nrow(Z) = 8 and length(y) = ncol(Z) = 3 must be satisfied.
如何创建一个 8 x 3 的矩阵以便我可以使用interp2
?
还是有更好的方法来执行这种插值?
谢谢你。