在 R 中获取曲面图

San*_*XGR 1 plot field r geometry-surface

我正在尝试从数据框中获取曲面图AAA

j     a           m  p       o            f
13929 0.86739583  19 165.83  0.1588727    13.24444
13930 0.63166667  19 178.19  0.6105804    12.68333
13932 0.90212963  17 157.77  0.3345627    12.52222
13933 0.80152778  68 146.19  0.1219885    12.35000
13934 0.75784722  62 134.88  0.1531627    12.36667
13935 0.57763889  66 123.80  0.4093869    12.47500
13936 0.56201389  88 112.87  0.9095722    12.45833
13937 0.51680556  26 102.03  0.8494420    12.37500
13938 0.46093333  28  91.20  0.9153419    12.21111
13939 0.16645833  24  80.30  0.8309784    12.04444
13940 0.15451389  36  69.23  2.2847927    12.15556
13941 0.51347222 134  57.92  2.9551087    12.42500
13942 0.33763889 128  46.31  3.5784096    12.53333
13943 0.12937500  38  34.33  3.7371723    12.47778
13944 0.42760870  63  22.00  4.7831677    12.46667
13945 0.09962121   8   9.36  4.8281897    12.30000
13950 0.97901515  18  57.70  0.0000000    12.15833
13951 0.85333333  14  71.07  0.0000000    12.48333
13952 0.92811594  14  84.28 10.0444672    12.49167
13953 0.84812500  42  97.29  7.8020987    12.51667
Run Code Online (Sandbox Code Playgroud)

我的代码:

require(fields)
fitx <- Tps( AAA[, 4:6], AAA$a)
out.p <- predict.surface(fitx, xy = c(4,5))
plot.surface(out.p, type="p")
Run Code Online (Sandbox Code Playgroud)

但是,它没有运行。显然,网格不足以表示数据并且无法获取predict.surface.

Sve*_*ein 5

Tps函数中,你的x矩阵是AAA[, 4:6],因此有三列。

但是在predict.surface函数中,您指定了xy = c(4,5). 传递给xy参数的值相对于fitx对象中的矩阵。由于用于创建矩阵fitxpredict.surface功能有三列,你不能引用第4和第5列。相反,原始 data.frame 的第 4 列和第 5AAA列对应于 中的第 1 列和第 2 列fitx

您可能希望尝试:

library(fields)
fitx <- Tps(AAA[, 4:6], AAA$a)
out.p <- predict.surface(fitx, xy = c(1,2)) # Note the different argument passed to `xy`
plot.surface(out.p, type="p")
Run Code Online (Sandbox Code Playgroud)