1

I have created the following interface using R shiny.

  library(shiny)




  ui <- fluidPage(
  #Can be fluid row also
  fluidRow(
  column(3,
       h3("Excel DB"),
       hr(),
       fileInput("file1", "Excel DB",
                 multiple = TRUE,
                 accept = c("text/csv/xlsx/xls",
                            "text/comma-separated-values,text/plain",
                            ".csv", ".xls", ".xlsx")),
       textInput(inputId = 'Type',label =  'Type'),
       textInput(inputId = 'Client',label =  'Client'),
       textInput(inputId = "Task", label = "Task"),
       actionButton(inputId = "ClearAll", label = "Clear Screen"),
       radioButtons("dist", "Vertical Axis Scale",
                    c("Linear" = "Linear Regression",
                      "Log" = "Logistic Regression"))
),
column(5,h5('              '),
       hr(), downloadButton(outputId = "Downloaddata", label = "Fetch Dataset"),
       textInput(inputId = "Commodity", label = "Commodity"),
       textInput(inputId = "Year", label = "Year"),
       radioButtons("dist", "Horizontal Axis Scale",
                    c("Linear" = "Linear Regression",
                      "Log" = "Logistic Regression")),
       numericInput(inputId = "Numberinput", label = "Numinput", min = -1000000000, max = 1000000000, value = 0,step = 1)

)
), sliderInput(inputId = "Scale", label = "Scale", min = 0, max = 100, step 
= 2.5, value = 1)
)

I have created the following empty server

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

The above code creates a shiny application with a sidebar panel having two columns. However, the 2 columns are not aligned with each other. I would like to know how to arrange the components of the app as follows.

The fetch dataset button should be along the browse button. Similarly the commodity text box should be next to type text box and the year box should come near the client. The two sets of radio buttons should align with each other. I request some help here. Am unable to arrange them in that pattern

Raghavan vmvs
  • 1,213
  • 1
  • 10
  • 29

1 Answers1

1

To achieve this you need to do some nesting of column() and fluidRow(). This answer should explain enough to get you started, along with the examples on Shiny's layout guide. I believe the following should get you roughly what you want:

library(shiny)

ui <- fluidPage(
  #Can be fluid row also
  h3("Excel DB"),
  hr(),
  fluidRow(
    column(12,
           fluidRow(
             column(3,
                    fileInput("file1", NULL,
                              multiple = TRUE,
                              accept = c("text/csv/xlsx/xls",
                                         "text/comma-separated-values,text/plain",
                                         ".csv", ".xls", ".xlsx"))),
             column(5,
                    column(3,
                           downloadButton(outputId = "Downloaddata", label = "Fetch Dataset")),
                    column(2, offset = 2,
                           actionButton(inputId = "ClearAll", label = "Clear Screen"))
                    )
           ),
           fluidRow(
             column(3,
                    textInput(inputId = 'Type',label =  'Type'),
                    textInput(inputId = 'Client',label =  'Client'),
                    textInput(inputId = "Task", label = "Task")
             ),
             column(5,
                    textInput(inputId = "Commodity", label = "Commodity"),
                    textInput(inputId = "Year", label = "Year"),
                    numericInput(inputId = "Numberinput", label = "Numinput", min = -1000000000, max = 1000000000, value = 0,step = 1)
             )),
           fluidRow(
             column(3,
                    radioButtons("dist", "Vertical Axis Scale",
                                 c("Linear" = "Linear Regression",
                                   "Log" = "Logistic Regression"))),
             column(5,
                    radioButtons("dist", "Horizontal Axis Scale",
                                 c("Linear" = "Linear Regression",
                                   "Log" = "Logistic Regression")))
             ),
           fluidRow(
             column(5,
                    sliderInput(inputId = "Scale", label = "Scale", min = 0, max = 100, 
                                step = 2.5, value = 1)) 
             )
           )
    )
  )

Created on 2018-09-20 by the reprex package (v0.2.1)

DanTan
  • 660
  • 7
  • 17