0
我正在尝试创建一个快速应用程序,让用户选择3个变量并使用scatter3D重新生成3D散点图。在使用闪光灯时我一直都会碰到这个错误,我看不出来纠正它。使用scatter3d和Shiny动态生成绘图
Error: not all arguments have the same length
我的代码也可以,如果更换:
x = paste("df.output$",input$test,sep=""),
y = paste("df.output$",input$test2,sep=""),
z = paste("df.output$",input$test3,sep=""),
与
x = df.output$age_scaled
y = df.output$freq_scaled
z = df.output$bonus_scaled
我的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()
})
})
谢谢!现在工作。对不起,图书馆混在一起。这正是你有什么,除了我有x = df.output [,输入$测试]。 – dchow