调整主面板在Shiny

时间:2018-09-21 04:47:14

标签: r shiny

我使用R Shiny创建了以下UI。脚本如下。

第一部分处理侧边栏布局。

 ui <- fluidPage(  
 titlePanel("Graphingtool"),  
  h3("DB"),
  hr(),
  fluidRow(
  column(12,
       fluidRow(
         column(3,
                fileInput("file1", 'DB',
                          multiple = TRUE,
                          accept = c("xlsx/xls",".xls",".xlsx"))),# We have added the formats here- will load excel alone- in case csv/txt needed amend here
         column(5,
                column(4,downloadButton(outputId = "Downloaddata", label = "Downloader"))
         )
       ),
       fluidRow(
         column(3,
                textInput(inputId = 'T',label =  'T'),
                textInput(inputId = 'C',label =  'C'),
                textInput(inputId = "P", label = "P"),

                column(2, offset = 2,
                       actionButton(inputId = "CLS", label = "CLS"))
         ),
         column(5,
                textInput(inputId = "P", label = "P"),
                textInput(inputId = "Y", label = "Y"),
                numericInput(inputId = "Numberinput", label = "Ninput", min = -1000000000, max = 1000000000, value = 0,step = 1)
         )),
       fluidRow(
         column(3,
                radioButtons("dist", "Vertical Axis Scale",
                             c("Linear" = "Linear Reg",
                               "Log" = "Log reg"))),
         column(5,
                radioButtons("dist", "Horizontal Axis Scale",
                             c("Linear" = "Linear reg",
                               "Log" = "Log reg")))
       ),
       fluidRow(
         column(5,
                sliderInput(inputId = "Scale", label = "Scale", min = 0, max = 100, 
                            step = 2.5, value = 1))) ) )

在这里我们创建主面板

 ,mainPanel(
  tabsetPanel(
  tabPanel("Plot", plotOutput("plot")), 
  tabPanel("Table", tableOutput("table"))
  )))        



 server<-function(input, output){reactive({})}
 shinyApp(ui, server)

我已经创建了主面板。但是,带有两个选项卡的面板在侧边栏面板下方而不是在面板右侧开口。

该脚本有效,但是可以打开侧边栏面板右侧的主面板。我要求有人在这里指导我。

1 个答案:

答案 0 :(得分:2)

看看这是否适合您。

    library(shiny)
ui <- fluidPage(  
  titlePanel("Graphingtool"),  
  h3("DB"),
  hr(),
  sidebarLayout(
    sidebarPanel(
               fluidRow(
                 column(5,
                        ailgn="center",
                        fileInput("file1", 'DB',
                                  multiple = TRUE,
                                  accept = c("xlsx/xls",".xls",".xlsx"))),# We have added the formats here- will load excel alone- in case csv/txt needed amend here
                 column(5,
                        ailgn="center",
                        HTML('<br/>'),
                        column(4,downloadButton(outputId = "Downloaddata", label = "Downloader"))
                 )
               ),
               fluidRow(
                 column(5,
                        ailgn="center",
                        textInput(inputId = 'T',label =  'T'),
                        textInput(inputId = 'C',label =  'C'),
                        textInput(inputId = "P", label = "P"),

                        column(2, offset = 2,
                               ailgn="center",
                               actionButton(inputId = "CLS", label = "CLS"))
                 ),
                 column(5,
                        ailgn="center",
                        textInput(inputId = "P", label = "P"),
                        textInput(inputId = "Y", label = "Y"),
                        numericInput(inputId = "Numberinput", label = "Ninput", min = -1000000000, max = 1000000000, value = 0,step = 1)
                 )),
               HTML('<br/>'),
               fluidRow(
                 column(5,
                        ailgn="center",
                        radioButtons("dist", "Vertical Axis Scale",
                                     c("Linear" = "Linear Reg",
                                       "Log" = "Log reg"))),
                 column(5,
                        ailgn="center",
                        radioButtons("dist", "Horizontal Axis Scale",
                                     c("Linear" = "Linear reg",
                                       "Log" = "Log reg")))
               ),
               fluidRow(
                 column(5,
                        ailgn="center",
                        sliderInput(inputId = "Scale", label = "Scale", min = 0, max = 100, 
                                    step = 2.5, value = 1))) 

    )
    ,mainPanel(
      tabsetPanel(
        tabPanel("Plot", plotOutput("plot")), 
        tabPanel("Table", tableOutput("table"))
      ))) 

    )
server<-function(input, output){reactive({})}
shinyApp(ui, server)

enter image description here

您可以通过调整列来调整大小