向前两步,后退一步。在过去的几个星期,我遇到了一些问题,我自己无法解决作为一个有着一年的R经验的自我推销用户,但幸运的是,在这个网站上有很多伟大的人,帮助我很多!首先,谢谢那些家伙。
现在看来,我们找到了一种方法,可以将scatter3d图放入我正在构建的闪闪发光的应用程序中,并使鼠标左键工作(请参阅前面的问题),我现在遇到了一个我不明白的bug。
bug说:经过一段时间的困惑之后,第3阶的主调不是正定的,我发现它是在scatter3d的椭球参数内。
运行此操作很好:
library(rgl)
library(car)
library(shiny)
colors <- rep("grey", 25) ### dummy palette of all greys
groups <- as.factor(rep(1:25,2)) ### make 5 categories
cars$time <- cars$dist/cars$speed
ui <- fluidPage(
hr("how do we get the plot inside this app window rather than in a popup?"),
rglwidgetOutput("plot", width = 800, height = 600)
)
server <- (function(input, output) {
output$plot <- renderRglwidget({
rgl.open(useNULL=F)
scatter3d(x=cars$speed, y=cars$dist, z=cars$time, surface=FALSE, ellipsoid = FALSE, groups = groups, surface.col = colors)
par3d(mouseMode = "trackball")
rglwidget()
})
})
shinyApp(ui = ui, server = server)切换到椭球体= TRUE会产生错误,没有任何东西在闪亮的情况下呈现。
只运行以下几行就可以不发光地运行图形:
rgl.open(useNULL=F)
scatter3d(x=cars$speed, y=cars$dist, z=cars$time, surface=FALSE, ellipsoid = TRUE, groups = groups, surface.col = colors)它的工作原理是在rgl窗口内呈现,但仍然打印错误。
将组数改为小于14组似乎解决了这个问题:组<- as.factor(rep(1:13,5))组<-组1:50
不会出错。组<- as.factor(rep(1:14,5))组<-组1:50给出错误.很奇怪。
起初,我认为它可能会链接到scatter3d颜色的nr中,因为最多有8个组,它不需要指定surface.col就会自动对事物着色。一旦你有9个组,你需要自己给它一个调色板,但这个13的截止似乎相当尴尬.
发布于 2017-05-27 09:08:35
你的问题是你根本没有足够的数据。这导致它在没有足够的点时尝试计算一个椭球(我想每个组至少需要3个)。错误信息显然会更好,但它不是错误的,它指的是在计算中出错的地方。
我创建了一个参数化的ncars,它只是对原始数据进行更大的重新采样,所以它应该看起来类似。
下面是:
library(rgl)
library(car)
library(shiny)
makebigcars <- function(n){
newspeed <- sample(cars$speed,n,replace=T)
newdist <- sample(cars$dist,n,replace=T)
bigcars <- data.frame(speed=newspeed,dist=newdist)
bigcars$time = bigcars$dist/bigcars$speed
return(bigcars)
}
ncars <- makebigcars(150)
n <- nrow(ncars)
colors <- rep("grey", n) ### dummy palette of all greys
groups <- as.factor(rep(1:5,n))[1:n] ## groups
ui <- fluidPage(
hr("Scatter3d"),
rglwidgetOutput("plot", width = 800, height = 600)
)
server <- (function(input, output) {
output$plot <- renderRglwidget({
rgl.open(useNULL=F)
scatter3d(x=ncars$speed, y=ncars$dist, z=ncars$time, surface=FALSE,
ellipsoid = T, groups = groups, surface.col = colors)
par3d(mouseMode = "trackball")
rglwidget()
})
})
shinyApp(ui = ui, server = server)下面是一个阴谋:

https://stackoverflow.com/questions/44214664
复制相似问题