![](/img/trans.png)
[英]Using Apply in R so that string (x) generates string (z) which is used to perform an operation with string (y)
[英]Derive the formula that from x and y generates z
我需要獲得具有 2 個變量(如x和y )生成結果z的數學公式。 我沒有關於公式類型的信息,但我有很多x 、 y和z值的例子。 在 R 中有一個包可以做到這一點嗎? 謝謝您的幫助。
不是公式,但可以進行插值。 使用akima包,您可以使用graph3d或plotly進行繪圖。
library(akima)
set.seed(666)
Grid <- expand.grid(x = 1:4, y = 1:4)
x <- Grid$x
y <- Grid$y
z <- rpois(16, 100)
itrp <- interp(x, y, z, linear = FALSE, extrap = TRUE)
outputGrid <- expand.grid(x = itrp$x, y = itrp$y)
dat <- data.frame(x = outputGrid$x, y = outputGrid$y, z = c(itrp$z))
dat <- subset(dat, !is.na(z))
library(graph3d)
graph3d(dat, keepAspectRatio = FALSE, verticalRatio = 1)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.