Hi Kentm,
I managed to develop the code as per my requirement , but only place i got stuck is 2 .csv outputs are displaying one below the other . But it supposed to be side by side.
Please find the code below and please help me out how to overcome this problem with Shiny App.
Thanks in advance.
library(shiny)
ui <- fluidPage(
fluidRow(
column(width = 6,
h2('The uploaded file data'),
dataTableOutput('mytable1'),
fileInput('file1', 'Choose info-file to upload',
accept = c(
'text/csv',
'text/comma-separated-values',
'text/tab-separated-values',
'text/plain',
'.csv',
'.tsv'
)
)
),
column(width = 6,
h2('The uploaded file data'),
dataTableOutput('mytable2'),
fileInput('file2', 'Choose info-file to upload',
accept = c(
'text/csv',
'text/comma-separated-values',
'text/tab-separated-values',
'text/plain',
'.csv',
'.tsv'
)
)
),
column(width=6,checkboxInput('header', 'Header', TRUE)),
column(width=6,checkboxInput('header', 'Header', TRUE)),
column(width=6,radioButtons('sep', 'Separator',
c(Comma=',',
Semicolon=';',
Tab='\t'),
',')),
column(width=6,radioButtons('sep', 'Separator',
c(Comma=',',
Semicolon=';',
Tab='\t'),
',')),
column(width=6,radioButtons('quote', 'Quote',
c(None='',
'Double Quote'='"',
'Single Quote'="'"),
'"')),
column(width=6,radioButtons('quote', 'Quote',
c(None='',
'Double Quote'='"',
'Single Quote'="'"),
'"')),
column(width=6,actionButton("choice", "incorporate external information1")),
column(width=6,actionButton("choice2", "incorporate external information2")),
column(width=6,selectInput("columns", "Select Columns", choices = NULL)),
column(width=6,selectInput("columns2", "Select Columns", choices = NULL)),
fluidRow(
column(width=3,div(style = "height:15px"),dataTableOutput("table_display1"))
),
fluidRow(
column(width=3,div(style = "height:15px"),dataTableOutput("table_display2"))
)
)
)
server <- function(input, output, session) {
info <- eventReactive(input$choice, {
inFile <- input$file1
req(inFile)
f <- read.table(inFile$datapath, header = input$header, sep = input$sep, quote = input$quote)
vars <- names(f)
updateSelectInput(session, "columns","Select Columns", choices = vars)
f
})
info2 <- eventReactive(input$choice2, {
inFile2 <- input$file2
req(inFile2)
f2 <- read.table(inFile2$datapath, header = input$header, sep = input$sep, quote = input$quote)
vars <- names(f2)
updateSelectInput(session, "columns2","Select Columns", choices = vars)
f2
})
output$table_display1 <- renderDataTable({
f <- info()
f <- subset(f, select = input$columns)
head(f)
})
output$table_display2 <- renderDataTable({
f2 <- info2()
f2 <- subset(f2, select = input$columns2)
head(f2)
})
}
shinyApp(ui, server)
ACTUAL OUTPUT:
EXPECTED should be side by side but i am not getting desired output with the code i shared above .