在R中获得曲面图

在R中获得曲面图,r,plot,field,geometry-surface,R,Plot,Field,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.1219

我试图从数据框
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
我的代码:

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

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

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

您可能希望尝试:

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")
库(字段)

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

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

您可能希望尝试:

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")
库(字段)

fitx如果没有
AAA
actrel
列,很难再现您的问题。请提供错误消息或结果
out.p
数据。“不运行”太模糊了。另一个想法是:如果您使用
graphics::persp
和所需的
AAA
子集生成曲面图,它看起来合理吗?对不起,我忘了更改代码第二行中的原始变量名称。请立即运行以查看错误消息如果没有
AAA
actrel
列,很难重现您的问题。请提供错误消息或结果
out.p
数据。“不运行”太模糊了。另一个想法是:如果您使用
graphics::persp
和所需的
AAA
子集生成曲面图,它看起来合理吗?对不起,我忘了更改代码第二行中的原始变量名称。请现在运行它以查看消息。非常感谢。那真的很容易!非常感谢你。那真的很容易!