gpt4 book ai didi

R Shiny 你能有一个导航栏和一个流畅的页面布局吗

转载 作者:行者123 更新时间:2023-12-03 16:43:31 25 4
gpt4 key购买 nike

我想创建一个带有导航栏的 Shiny 应用程序,但也能够使用流体行()和流体列()在页面上配置布局。

我在这里阅读了“导航栏页面”和“流体网格系统”区域http://shiny.rstudio.com/articles/layout-guide.html在流体网格系统下,它说“要根据流体系统创建布局,请使用流体页面()函数。”所以这是我的例子:

服务器文件

shinyUI(navbarPage("",
tabPanel("test",
#THIS IS THE SIDEBAR INPUT PANEL
column(2,wellPanel(
selectInput("x", "x:", c(5, 10,30,60),selected = 5)
)),

#THIS IS THE MAIN CONTENT
column(10,
fluidRow( plotOutput("plot3")) #,

#fluidRow(
# column(width=5, plotOutput("plot2")),
# column(width=5, plotOutput("plot3"))
# )
)#end of main body columns
)#end tab panel

,
tabPanel("summary",
verbatimTextOutput("summary")
),
navbarMenu("More Info",
tabPanel("Test1",
dataTableOutput("table")
)
)
))


ui.r

library(shinydashboard)
library(reshape)
library(quantmod)
library(ggplot2)
library(reshape2)
library(scales)

shinyServer(function(input, output, session) {
output$plot1 <- renderPlot({
#plot(cars, type=input$plotType)
plot(c(1))
})

output$plot2 <- renderPlot({
#plot(cars, type=input$plotType)
plot(c(100))
})

output$plot3 <- renderPlot({
#plot(cars, type=input$plotType)
plot(c(-2001))
})


output$summary <- renderPrint({
summary(cars)
})

output$table <- renderDataTable({
cars
}, options=list(pageLength=10))
})#### END OF SHINY SERVER FUNCTION

所以上面的代码有效并且它有一个导航栏。但是我想在“测试”选项卡面板的 ui.r 页面上添加另一个流体行。你可以看到我注释掉了这些行:
                                  #fluidRow( 
# column(width=5, plotOutput("plot2")),
# column(width=5, plotOutput("plot3"))
# )

我想取消注释它们并显示一个带有 2 列的流体行。但是当我取消注释这些行时,应用程序不会返回任何内容。

那么是否有可能有一个导航栏页面并进行像这样的流畅布局?

或者我需要使用fluidPage()而不是navBarPage()吗?但是那你怎么用fluidPage做一个导航栏??

最佳答案

是的你可以。

它在 documentation 中说您可以使用 fluid = TRUE 打开此功能:

fluid TRUE to use a fluid layout. FALSE to use a fixed layout.

关于R Shiny 你能有一个导航栏和一个流畅的页面布局吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32638282/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com