akima和/或rgl正在关闭Rstudio

时间:2016-10-25 19:08:46

标签: rstudio rgl

以下过程正在关闭我的Rstudio:我理解是任何akima或rgl包或两者兼而有之。怎么解决这个?数据here

s=read.csv("GRVMAX tadpoles.csv")
require(nlme) 
t=s[s$SPP== levels(s$SPP)[1],]
head(t)
t=na.omit(t)
t$TEM=as.numeric(as.character(t$TEM))


library(akima)
x=t$TEM
y=t$value
z=t$time
spline <- with(t,interp(x,y,z,duplicate="median",linear=T))
# rotatable 3D plot of points and spline surface
library(rgl)
open3d(scale=c(1/diff(range(x)),1/diff(range(y)),1/diff(range(z))))
with(spline,surface3d(as.character(x),y,z, col))

points3d(x,y,z, add=T)
title3d(xlab="temperature",ylab="performance",zlab="time")
axes3d()

1 个答案:

答案 0 :(得分:0)

interp()会导致问题。我认为原因是y的尺度与x大不相同(interp()的算法基本上是空间地图的轮廓)。所以interp()会在你改变比例时运行。 (注意;我做了y*10output/10,但也许这是一个粗略的规模变化。它可以更好地改变规模的变化方法。

library(nlme); library(akima); library(rgl)

s = read.csv("GRVMAX tadpoles.csv")
t = s[s$SPP == levels(s$SPP)[1],]
t = na.omit(t)
head(t)
t$TEM = as.numeric(as.character(t$TEM))

x = t$TEM
y = t$value * 10                # scale change
z = t$time

spline <- interp(x, y, z, duplicate = "median", linear = T)  # with() is unnecessary
spline$y <- spline$y / 10       # rescale
y <- y / 10                     # rescale

open3d()                                      # Is scale needed ??
 # persp3d() can directly take interp.obj as an argument
persp3d(spline, col = "blue", alpha = 0.5, axes = F, xlab="", ylab="", zlab="")
points3d(x, y, z, add=T)
title3d(xlab="temperature", ylab="performance", zlab="time")
axes3d()

enter image description here