0
在下面的玩具例子中,我在側邊欄中有很多滑塊。對於最後一個,我看不到右邊的情節了。有沒有解決這個問題,不涉及刪除滑塊?側邊欄太長時閃亮時該怎麼辦?
# 01-kmeans-app
palette(c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3",
"#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999"))
library(shiny)
ui <- fluidPage(
headerPanel('Iris k-means clustering'),
sidebarPanel(
selectInput('xcol', 'X Variable', names(iris)),
selectInput('xcol', 'X Variable', names(iris)),
selectInput('xcol', 'X Variable', names(iris)),
selectInput('xcol', 'X Variable', names(iris)),
selectInput('xcol', 'X Variable', names(iris)),
selectInput('xcol', 'X Variable', names(iris)),
selectInput('xcol', 'X Variable', names(iris)),
selectInput('xcol', 'X Variable', names(iris)),
selectInput('xcol', 'X Variable', names(iris)),
selectInput('xcol', 'X Variable', names(iris)),
selectInput('ycol', 'Y Variable', names(iris),
selected = names(iris)[[2]]),
numericInput('clusters', 'Cluster count', 3,
min = 1, max = 9)
),
mainPanel(
plotOutput('plot1')
)
)
server <- function(input, output) {
selectedData <- reactive({
iris[, c(input$xcol, input$ycol)]
})
clusters <- reactive({
kmeans(selectedData(), input$clusters)
})
output$plot1 <- renderPlot({
par(mar = c(5.1, 4.1, 0, 1))
plot(selectedData(),
col = clusters()$cluster,
pch = 20, cex = 3)
points(clusters()$centers, pch = 4, cex = 4, lwd = 4)
})
}
shinyApp(ui = ui, server = server)
我沒有看到你的代碼中的任何滑塊?你的意思是'selectInput's?當我運行你的代碼時,我會看到完整的圖形和側欄中的一長串輸入。側邊欄與圖表重疊嗎? – Chris
是的,我認爲一個滑塊就是調用'selectInput'的東西。如果你仍然可以看到它,那麼只需添加更多,直到看不到該圖。我的問題是當你達到那一點時要做什麼。 –