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