Raghavan vmvs
Raghavan vmvs

Reputation: 1265

Adjusting location of Main panel in Shiny

I have created the following UI using R shiny. The script is as follows.

The first part deals with the sidebar layout.

 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))) ) )

Here we create the main panel

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



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

I Have created the main panel. However, the Panel with two tabs is opening under the sidebar panel and not on the right hand side of the panel.

The script works but is it possible to open the main panel on the right of the sidebar panel. I request someone to guide me here.

Upvotes: 1

Views: 2087

Answers (1)

Subhasish1315
Subhasish1315

Reputation: 978

Take a look on this if this okay or not for you..

    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

You can tweak the size by adjusting column

Upvotes: 3

Related Questions