Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 当侧边栏太长时怎么办?_R_Shiny - Fatal编程技术网

R 当侧边栏太长时怎么办?

R 当侧边栏太长时怎么办?,r,shiny,R,Shiny,在下面的玩具示例中,我在侧边栏中有很多滑块。最后几次,我再也看不到正确的情节了。这个问题有没有不涉及删除滑块的解决方案 # 01-kmeans-app palette(c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3", "#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999")) library(shiny) ui <- fluidPage( headerPanel('Iris k-me

在下面的玩具示例中,我在侧边栏中有很多滑块。最后几次,我再也看不到正确的情节了。这个问题有没有不涉及删除滑块的解决方案

# 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)
#01 kmeans应用程序
调色板(c(“#E41A1C”、“#377EB8”、“#4DAF4A”、“#984EA3”,
“FF7F00”、“FFFF33”、“A65628”、“F781BF”、“999999”))
图书馆(闪亮)

ui您可以尝试向侧面板添加向下滚动条

多亏了

#01 kmeans应用程序
调色板(c(“#E41A1C”、“#377EB8”、“#4DAF4A”、“#984EA3”,
“FF7F00”、“FFFF33”、“A65628”、“F781BF”、“999999”))
图书馆(闪亮)

ui我在你的代码中没有看到任何滑块?你是说
selectInput
s?当我运行代码时,我会在侧边栏中看到完整的图形和一长串输入。侧边栏是否与图形重叠?是的,我认为滑块是
selectInput
的名称。如果您仍然可以看到它,那么只需添加更多这些,直到您无法看到绘图。我的问题是当你达到这一点时该怎么做。
# 01-kmeans-app

palette(c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3",
          "#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999"))

library(shiny)

ui <- fluidPage(
    headerPanel('Iris k-means clustering'),
    sidebarPanel(id = "tPanel",style = "overflow-y:scroll; max-height: 600px; position:relative;",
        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)