使用scatter3d和Shining动态生成绘图

使用scatter3d和Shining动态生成绘图,r,shiny,rgl,r-car,scatter3d,R,Shiny,Rgl,R Car,Scatter3d,我正在尝试创建一个快速应用程序,允许用户选择3个变量,并使用scatter3D重新生成3D散射。我在使用shiny时一直碰到这个错误,我看不到可以纠正它 错误:并非所有参数都具有相同的长度 我的代码在以下情况下也有效: x = paste("df.output$",input$test,sep=""), y = paste("df.output$",input$test2,sep=""), z = paste("df.output$",input$test3,sep=""), 与 我的ui函数

我正在尝试创建一个快速应用程序,允许用户选择3个变量,并使用scatter3D重新生成3D散射。我在使用shiny时一直碰到这个错误,我看不到可以纠正它

错误:并非所有参数都具有相同的长度

我的代码在以下情况下也有效:

x = paste("df.output$",input$test,sep=""),
y = paste("df.output$",input$test2,sep=""),
z = paste("df.output$",input$test3,sep=""),

我的ui函数如下所示

ui <- fluidPage(
  titlePanel("3 Dimensional Cluster Analysis"),
  sidebarLayout( 
  sidebarPanel(
  selectInput("test", "X-Axis", choices=colnames(df.output) , 
  selected=colnames(df.output[1]), width = NULL, size = NULL),
    selectInput("test2", "Y-Axis", choices=colnames(df.output), 
  selected=colnames(df.output[2]), width = NULL, size = NULL),
    selectInput("test3", "Z-Axis", choices=colnames(df.output), 
  selected=colnames(df.output[3]), width = NULL, size = NULL)),

   mainPanel(
    rglwidgetOutput("plot",  width = 1000, height = 500)
      )
    ))
library(rgl)

server <- (function(input, output) 
{
  # reactive({
  #   a <- paste("df.output$",test$input,sep="")
  # })
  output$plot <- renderRglwidget(
    {
      rgl.open(useNULL=T)
      scatter3d(
        x = paste("df.output$",input$test,sep=""),
        y = paste("df.output$",input$test2,sep=""),
        z = paste("df.output$",input$test3,sep=""),
        groups = as.factor(df.output$Cluster), 
        grid=FALSE,
        surface=FALSE,
        ellipsoid=TRUE,
        ellipsoid.alpha=0.5,
        fit=smooth,
        xlab=input$test,
        ylab=input$test2,
        zlab=input$test3
      )
       par3d(mouseMode = "trackball")
       rglwidget() 
     })
})   
ui您的代码

x = paste("df.output$",input$test,sep="")
将x设置为长度为1的字符向量。如果要从数据帧中选择组件,请使用

x = df.output[[input$test]]

您的代码也不使用包含
scatter3d
的包(它不是
rgl
函数)。在
car
包中有一个同名函数,在
plot3D
包中有一个类似的名称

谢谢!现在工作。对不起,图书馆弄错了。除了我有x=df.output[,input$test]之外,这正是您所拥有的。
x = df.output[[input$test]]