Error while uploading a file using file input - r

I am trying to develop an application, that could help the users upload a file and display the summary statistics.
I am using the below UI and Server code to achieve this, once I have completed my file upload, i am unable to see the data frame and its summary statistics.
I am missing something with my code, but unable to guess.
ui<-dashboardPage(
dashboardHeader(title = "Claim Model"),
dashboardSidebar(
sidebarMenu(id="tabs",
menuItem("Data", tabName = "data", icon = icon("table"),startExpanded = TRUE,
menuSubItem("Load", tabName = "data1")
),
menuItem("Visualisation",icon=icon("bar-chart-o"), tabName = "vis"),
menuItem("Result", icon=icon("cog"), tabName = "result")
)
),
dashboardBody(
tags$style(type="text/css",
".shiny-output-error { visibility: hidden; }",
".shiny-output-error:before { visibility: hidden; }"
),
tabItems(
tabItem(tabName = "data1",
fluidPage(
fluidRow(
fileInput("file1","Choose CSV File",
accept = c("text/csv",
"text/comma-seperated-values, text/plain",
".csv")
),
tags$hr(),
checkboxInput("header", "Header", TRUE),
radioButtons("sep","Separator",
choices=c(Comma=",",
semicolon=";",
Tab="\t"),
selected = ";")
),
mainPanel(
tableOutput("contents")
)
)
)
)
)
)
Server Code.
server <- shinyServer(function(input,output){
output$contents <- renderTable({
req(input$file1)
df <- read.csv(input$file1$datapath,
header=input$header,
sep=input$sep)
})
})
Currently i dont have the code for displaying the statistics from data frame. any lead on how to start would be helpful

Here is an example: Inside dashboardBody(), you need a second (and third) tabItem() to "fill" the menuItem(tabName = "vis") and menuItem(tabName = "result"). And in the server, you need code to generate plots or tables or whatever you want to display. Furthermore, note how I assigned the output of read.csv() to a function (called DATA() here) so that it can be used at different places inside the server.
UI:
ui <- dashboardPage(
dashboardHeader(title = "Claim Model"),
dashboardSidebar(
sidebarMenu(id="tabs",
menuItem("Data", tabName = "data", icon = icon("table"),startExpanded = TRUE,
menuSubItem("Load", tabName = "data1")
),
menuItem("Visualisation",icon=icon("bar-chart-o"), tabName = "vis"),
menuItem("Result", icon=icon("cog"), tabName = "result")
)
),
dashboardBody(
tags$style(type="text/css",
".shiny-output-error { visibility: hidden; }",
".shiny-output-error:before { visibility: hidden; }"
),
tabItems(
tabItem(tabName = "data1",
fluidPage(
fluidRow(
fileInput("file1","Choose CSV File",
accept = c("text/csv",
"text/comma-seperated-values, text/plain",
".csv")
),
tags$hr(),
checkboxInput("header", "Header", TRUE),
radioButtons("sep","Separator",
choices=c(Comma=",",
semicolon=";",
Tab="\t"),
selected = ";")
),
mainPanel(
tableOutput("contents")
)
)
),
tabItem(tabName = "vis", h2("Two Plots"),
fluidRow(
box(
title = "Plot 1", solidHeader = TRUE, collapsible = TRUE,
plotOutput("hist1")
),
box(
title = "Plot 2", solidHeader = TRUE, collapsible = TRUE,
plotOutput("hist2")
)
)
)
)
)
)
server:
server <- function(input, output) {
DATA <- reactive({
req(input$file1)
df <- read.csv(input$file1$datapath,
header = input$header,
sep = input$sep)
return(df)
})
output$contents <- renderTable(DATA())
output$hist1 <- renderPlot({
tmp1 <- sample(which(apply(DATA(), 2, is.numeric)), 1)
hist(DATA()[, tmp1], breaks = 10, xlab = names(DATA())[tmp1], main = "")
})
output$hist2 <- renderPlot({
tmp1 <- sample(which(apply(DATA(), 2, is.numeric)), 1)
hist(DATA()[, tmp1], breaks = 20, xlab = names(DATA())[tmp1], main = "")
})
}
run:
library(shiny)
library(shinydashboard)
shinyApp(ui, server)

Related

Possible Reactive function for PDF download in Shiny

I'm wondering if it's possible to have a shiny app being able to download a PDF of selected table content.
For example, if I have two tables, and I select one table to be downloaded via PDF, it will download a PDF that has the title content I want and the specified table in a PDF format. Not sure how I can change the downloadHandler portion so that the PDF download works and not give me the following error:
Warning: Error in FUN: non-numeric argument to binary operator [No
stack trace available]
.
The code is as follows:
df1<- data.frame(c(1:4),c("Z","Y","X","A"))
df2<- data.frame(c("Apple","Orange"),c(6.99,4.99))
colnames(df1)<-c("Col1","Col2")
colnames(df2)<-c("ColA","ColB")
library(shiny)
library(Cairo)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title="Test"),
dashboardSidebar(sidebarMenu(
menuItem("Data Table", tabName = "dashboard", icon = icon("th")))),
dashboardBody(tabItems(
# First tab content
tabItem(tabName = "dashboard",
fluidRow(
box(downloadButton("download", "PDF Download"),
radioButtons(inputId="filter1", label="Table", choiceNames = c("One","Two"), choiceValues = c("df1","df2"),inline= TRUE))),
fluidRow(box(
column(8, align="center", offset = 2,tags$b(textOutput("text1"))),
br(),br(),br(),br(),
textOutput("text2"),
tableOutput("static1"),
width=12))
)))
)
server <- function(input, output) {
output$text1 <- renderText({ "This Table" })
output$text2 <- renderText({"PR"})
df02 <- reactive({
get(input$filter1)
})
output$static1 <- renderTable({
df02()
})
output$download <- downloadHandler(
filename = 'report.pdf',
content = function(file) {
cairo_pdf(filename = "file123.pdf",
df02())
}, contentType = "application/pdf"
)
}
shinyApp(ui, server)
It seems that the PDF download does not work. I want the downloaded PDF to look like this when I select Table One and click on the PDF download button:
I want the downloaded PDF to look like this when I select Table Two to be downloaded:
df1 <- data.frame(c(1:4), c("Z", "Y", "X", "A"))
df2 <- data.frame(c("Apple", "Orange"), c(6.99, 4.99))
colnames(df1) <- c("Col1", "Col2")
colnames(df2) <- c("ColA", "ColB")
library(shiny)
library(shinydashboard)
library(xtable)
library(withr)
library(shinybusy)
ui <- dashboardPage(
dashboardHeader(title = "Test"),
dashboardSidebar(sidebarMenu(
menuItem("Data Table", tabName = "dashboard", icon = icon("th"))
)),
dashboardBody(
add_busy_spinner(spin = "cube-grid", onstart = FALSE),
tabItems(
# First tab content
tabItem(
tabName = "dashboard",
fluidRow(
box(
downloadButton("download", "PDF Download"),
radioButtons(
inputId = "filter1", label = "Table", inline = TRUE,
choiceNames = c("One", "Two"), choiceValues = c("df1", "df2")
)
)
),
fluidRow(box(
column(8, align = "center", offset = 2, tags$b(textOutput("text1"))),
br(), br(), br(), br(),
textOutput("text2"),
tableOutput("static1"),
width = 12
))
)
)
)
)
server <- function(input, output) {
output$text1 <- renderText({
"This Table"
})
output$text2 <- renderText({
"PR"
})
df02 <- reactive({
get(input$filter1)
})
output$static1 <- renderTable({
df02()
})
output[["download"]] <- downloadHandler(
filename = "results_from_shiny.pdf",
content = function(file){
texfile <- paste0(tools::file_path_sans_ext(file), ".tex")
latex <- print.xtable(
xtable(df02()), print.results = FALSE,
floating = FALSE, scalebox = "0.9"
)
writeLines(
c(
"\\documentclass[12pt]{standalone}",
"\\usepackage{graphics}",
"\\usepackage{caption}",
"\\begin{document}",
"{\\large\\bf This table.}",
"",
"\\newline",
"",
"\\minipage{\\textwidth}",
"\\centering",
latex,
"\\captionof{table}{My caption}",
"\\endminipage",
"\\end{document}"
),
texfile
)
with_dir(
dirname(texfile),
tools::texi2pdf(texfile, clean = TRUE)
)
}, contentType = "application/pdf"
)
}
shinyApp(ui, server)
EDIT
Or you can use the capture package:
tabItem(
tabName = "dashboard",
fluidRow(
box(
capture::capture_pdf(
selector = "#table-container",
filename = "table.pdf",
icon("camera"), "Take screenshot of table."
),
radioButtons(
inputId = "filter1", label = "Table", , inline = TRUE,
choiceNames = c("One", "Two"), choiceValues = c("df1", "df2")
)
)
),
fluidRow(box(
id = "table-container",
column(8, align = "center", offset = 2, tags$b(textOutput("text1"))),
br(), br(), br(), br(),
textOutput("text2"),
tableOutput("static1"),
width = 12
))
)

R shinydashboard collapsible menuItem with inputs

I am trying to implement a fileInput using library(shinydashboard) to provide the user with the option to upload files (as it was done here with a basic shiny UI - please find the example code below).
I would like to place the fileInput in the dashboardSidebar in an expandable menuItem, but don't know where it should go into the shinydashboard structure.
library(shiny)
ui <- fluidPage(
titlePanel("Uploading Files"),
sidebarLayout(
sidebarPanel(
fileInput("file1", "Choose CSV File",
multiple = TRUE,
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv")),
tags$hr(),
checkboxInput("header", "Header", TRUE),
radioButtons("sep", "Separator",
choices = c(Comma = ",",
Semicolon = ";",
Tab = "\t"),
selected = ","),
radioButtons("quote", "Quote",
choices = c(None = "",
"Double Quote" = '"',
"Single Quote" = "'"),
selected = '"'),
tags$hr(),
radioButtons("disp", "Display",
choices = c(Head = "head",
All = "all"),
selected = "head")
),
mainPanel(
tableOutput("contents")
)
)
)
server <- function(input, output) {
output$contents <- renderTable({
req(input$file1)
df <- read.csv(input$file1$datapath,
header = input$header,
sep = input$sep,
quote = input$quote)
if(input$disp == "head") {
return(head(df))
}
else {
return(df)
}
})
}
shinyApp(ui, server)
Edit: I cleaned up the code a little to make the difference between childfull and childless menuItem's more clear - the parameters expandedName and startExpanded can only be used with a childfull menuItem in contrast tabName and selected is only used with childless menuItem's.
library(shiny)
library(shinydashboard)
ui <- function(req) {
dashboardPage(
dashboardHeader(title = "Simple tabs"),
dashboardSidebar(sidebarMenu(
id = "sidebarItemSelected",
menuItem(
"Childfull menuItem",
menuItem(
"Childless menuItem 1",
tabName = "childlessTab1",
icon = icon("dashboard"),
selected = TRUE
),
fileInput("upload", "Upload"),
bookmarkButton(),
expandedName = "childfullMenuItem",
startExpanded = TRUE
),
menuItem(
"Childless menuItem 2",
icon = icon("th"),
tabName = "childlessTab2",
badgeLabel = "new",
badgeColor = "green"
)
)),
dashboardBody(tabItems(
tabItem(tabName = "childlessTab1",
h2("Dashboard tab content")),
tabItem(tabName = "childlessTab2",
h2("Widgets tab content"))
))
)
}
server <- function(input, output, session) {
observe({
cat(
paste(
"\nsidebarItemSelected:",
input$sidebarItemSelected,
"\nsidebarItemExpanded:",
input$sidebarItemExpanded,
"\nsidebarCollapsed:",
input$sidebarCollapsed,
"\n"
)
)
})
}
shinyApp(ui, server, enableBookmarking = "url")
Initial answer:
Sure - this is possible (modified version of this example):
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Simple tabs"),
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", fileInput("upload", "Upload"), tabName = "dashboard", icon = icon("dashboard")),
menuItem("Widgets", icon = icon("th"), tabName = "widgets",
badgeLabel = "new", badgeColor = "green")
)
),
dashboardBody(
tabItems(
tabItem(tabName = "dashboard",
h2("Dashboard tab content")
),
tabItem(tabName = "widgets",
h2("Widgets tab content")
)
)
)
)
server <- function(input, output, session) {}
shinyApp(ui, server)

Error: argument "expr" is missing, with no default

So I'm trying to make a dashboard in R Shiny where in the first tab, users can input their data in csv file. And in the second tab they will see the summary and plot of their data. In the sub-tab Plot, the users will have to choose xlabel and ylabel from the dataset columns an the Plot A will show the scatter plot of xlabel and y label.
ui <- dashboardPage(skin='red',
dashboardHeader(title = "Dashboard"),
## Sidebar content
dashboardSidebar(
sidebarMenu(
menuItem("Data", tabName = "dashboard"),
menuItem("Visualization", tabName = "viz",
menuSubItem("Summary",tabName="sum"),
menuSubItem("Plot",tabName = "plot")),
menuItem("Interpretation", tabName = "int")
) ),
## Body content
dashboardBody(
tabItems(
# First tab content
tabItem(tabName = "dashboard",
fluidPage(titlePanel("DATA"),
fluidRow(
column(width=4,
fileInput("file1", "Input CSV file",
multiple = TRUE,
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv"))),
column(width=2,checkboxInput("header", "Header", TRUE)),
column(width=2,radioButtons("sep","Separator",
choices = c(Comma=",",
Semicolon = ";",
Tab = "\t"),
selected = ",")),
column(width=2,radioButtons("quote", "Quote",
choices = c(None = "",
"Double Quote" = '"',
"Single Quote" = "'"),
selected = '"')),
column(width=2,radioButtons("disp", "Display",
choices = c(Head = "head",
All = "all"),
selected = "head"))
),
tableOutput("contents")
)),
# Second tab content
tabItem(tabName = "sum",
box(
title="Summary",
status="primary",
solidHeader = TRUE,
width = "100%",
collapsible = TRUE,
verbatimTextOutput("summary")
)
),
tabItem(tabName="plot",
h2("Plot"),
fluidRow(
selectInput("sip","select",choices = 1:10),
selectInput("sila","anda",choices = 1:10)
),
fluidRow(
box(
title = "Plot A",
status= "primary",
solidHeader = TRUE,
collapsible = TRUE,
plotOutput("plota",height="300px")
),
box(
title = "Plot B",
status= "primary",
solidHeader = TRUE,
collapsible = TRUE,
plotOutput("plotb",height="300px"
)
)
)),
tabItem(tabName = "int",
h2("hello")
)
)
))
server <- function(input, output,session) {
output$contents <- renderTable({
# input$file1 will be NULL initially. After the user selects
# and uploads a file, head of that data file by default,
# or all rows if selected, will be shown.
req(input$file1)
df <- read.csv(input$file1$datapath,
header = input$header,
sep = input$sep,
quote = input$quote)
if(input$disp == "head") {
return(head(df))
}
else {
return(df)
}
})
output$summary <- renderPrint({
req(input$file1)
dataset<- read.csv(input$file1$datapath,
header = input$header,
sep = input$sep,
quote = input$quote)
summary(dataset)
})
output$plota <- renderPlot({
req(input$file1)
dataset<- read.csv(input$file1$datapath,
header = input$header,
sep = input$sep,
quote = input$quote)
updateSelectInput(session,"sip",label="label",choices=names(dataset))
updateSelectInput(session,"sila",label="label",choices = names(dataset))
plot(dataset[eventReactive(input$sip)],dataset[eventReactive(input$sila)],pch=19)
})
output$plotb <- renderPlot({
})
}
shinyApp(ui, server)
This is how the code looks like. When i run this program, it result in error: argument "expr" is missing, with no default. What is expr in this context?
You don't need to use eventReactive since renderPlot is a reactive expression, use only the input$..
Another problem is that you are trying to update the selectImput's inside the renderPlot, which is not going to work. You should update them with a different reactive expression, like a reactive() where you can also read the file instead of reading it multiple times. Below is your code modified to solve the problem and also reading the file only once inside a reactive expression.
library(shiny)
library(shinydashboard)
ui <- dashboardPage(skin='red',
dashboardHeader(title = "Dashboard"),
## Sidebar content
dashboardSidebar(
sidebarMenu(
menuItem("Data", tabName = "dashboard"),
menuItem("Visualization", tabName = "viz",
menuSubItem("Summary",tabName="sum"),
menuSubItem("Plot",tabName = "plot")),
menuItem("Interpretation", tabName = "int")
) ),
## Body content
dashboardBody(
tabItems(
# First tab content
tabItem(tabName = "dashboard",
fluidPage(titlePanel("DATA"),
fluidRow(
column(width=4,
fileInput("file1", "Input CSV file",
multiple = TRUE,
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv"))),
column(width=2,checkboxInput("header", "Header", TRUE)),
column(width=2,radioButtons("sep","Separator",
choices = c(Comma=",",
Semicolon = ";",
Tab = "\t"),
selected = ",")),
column(width=2,radioButtons("quote", "Quote",
choices = c(None = "",
"Double Quote" = '"',
"Single Quote" = "'"),
selected = '"')),
column(width=2,radioButtons("disp", "Display",
choices = c(Head = "head",
All = "all"),
selected = "head"))
),
tableOutput("contents")
)),
# Second tab content
tabItem(tabName = "sum",
box(
title="Summary",
status="primary",
solidHeader = TRUE,
width = "100%",
collapsible = TRUE,
verbatimTextOutput("summary")
)
),
tabItem(tabName="plot",
h2("Plot"),
fluidRow(
selectInput("sip","select",choices = 1:10),
selectInput("sila","anda",choices = 1:10)
),
fluidRow(
box(
title = "Plot A",
status= "primary",
solidHeader = TRUE,
collapsible = TRUE,
plotOutput("plota",height="300px")
),
box(
title = "Plot B",
status= "primary",
solidHeader = TRUE,
collapsible = TRUE,
plotOutput("plotb",height="300px"
)
)
)),
tabItem(tabName = "int",
h2("hello")
)
)
))
server <- function(input, output,session) {
dataset <- reactive({
req(input$file1)
dat <- read.csv(input$file1$datapath,
header = input$header,
sep = input$sep,
quote = input$quote)
updateSelectInput(session,"sip",choices=names(dat))
updateSelectInput(session,"sila",choices = names(dat))
dat
})
output$contents <- renderTable({
# input$file1 will be NULL initially. After the user selects
# and uploads a file, head of that data file by default,
# or all rows if selected, will be shown.
req(input$file1)
df <- dataset()
if(input$disp == "head") {
return(head(df))
}
else {
return(df)
}
})
output$summary <- renderPrint({
req(input$file1)
summary(dataset())
})
output$plota <- renderPlot({
plot(dataset()[[input$sip]],dataset()[[input$sila]],pch=19)
})
output$plotb <- renderPlot({
})
}
shinyApp(ui, server)

Render variables from file input

I am trying to develop an application, where I have designed my dashboard with two menu sub items.
Load
Prep
In Load, I am using File input, to allow the user to upload the file.
2 .In prep, I want to display the headers from the file in the form of checkgroupbox.
For that, I have tried the below code. In the below code, I have following problems.
1. The selection of variables, I need in Prep, is available in Load.
Select variables, I want to display them in checkbox, so the user can select the variables they want.
Here is my code, Could anyone help me how I could achieve it?
ui<-dashboardPage(
dashboardHeader(title = "Model"),
dashboardSidebar(
sidebarMenu(id="tabs",
menuItem("Data", tabName = "data", icon = icon("table"),startExpanded = TRUE,
menuSubItem("Load", tabName = "data1"),
menuSubItem("Prep", tabName = "prep")
),
menuItem("Visualisation",icon=icon("bar-chart-o"), tabName = "vis"),
menuItem("Result", icon=icon("cog"), tabName = "result")
)
),
dashboardBody(
tags$style(type="text/css",
".shiny-output-error { visibility: hidden; }",
".shiny-output-error:before { visibility: hidden; }"
),
tabItems(
tabItem(tabName = "data1",
fluidPage(
fluidRow(
fileInput("file1","Choose CSV File",
accept = c("text/csv",
"text/comma-seperated-values, text/plain",
".csv")
),
tags$hr(),
checkboxInput("header", "Header", TRUE),
radioButtons("sep","Separator",
choices=c(Comma=",",
semicolon=";",
Tab="\t"),
selected = ";")
),
mainPanel(
uiOutput("tb")
)
)
)
),
tabItem(tabName = "prep",
fluidPage(
fluidRow(
h5("Select Varibales")
),
mainPanel(
uiOutput("Pre")
)
))
)
)
server <- shinyServer(function(input,output){
data <- reactive({
file1 <- input$file1
if(is.null(file1)){return()}
read.csv(file = file1$datapath, sep=input$sep)
})
output$filedf <- renderTable({
if(is.null(data())){return()}
input$file1
})
output$sum <- renderTable({
if(is.null(data())){return()}
summary(data())
})
output$table <- renderTable({
if(is.null(data())){return()}
data()
})
output$tb <- renderUI({
if(is.null(data())){return()}
tabsetPanel(tabPanel("About file", tableOutput("filedf")),tabPanel("Data", tableOutput("table")),tabPanel("Summary", tableOutput("sum")))
})
#----- Data Preparation------
output$Pre <- renderUI({checkboxGroupInput(inputId = "select_vars",
label="Select Variables",
choices = names(data))
})
data_sel <- reactive({
req(input$select_vars)
data_sel<- data()%>% select(input$select_var)
})
})
shinyApp(ui,server)

Using Fileinput to upload files

I am trying to develop an app with a dashboard design to display the summary of the table and display the data frame.
I am quite unsuccessful, in designing it. I have incorporated my own dashboard design for this.
I am missing an element in my server function and not able to see the dataframe of the uplaoded file.
Any lead would be helful.
Below is my code for the UI and Server function
UI
ui <- dashboardPage(
dashboardHeader(title = "Model"),
dashboardSidebar(sidebarMenu(
id = "tabs",
menuItem(
"Data",
tabName = "data",
icon = icon("table"),
startExpanded = TRUE,
menuSubItem("Load", tabName = "data1")
),
dashboardBody(
tags$style(
type = "text/css",
".shiny-output-error { visibility: hidden; }",
".shiny-output-error:before { visibility: hidden; }"
),
tabItems(tabItem(
tabName = "data1",
fluidPage(
fluidRow(
fileInput(
"file",
"Choose CSV File",
accept = c("text/csv",
"text/comma-seperated-values, text/plain",
".csv")
),
tags$hr(),
checkboxInput("header", "Header", TRUE),
radioButtons(
"sep",
"Separator",
choices = c(
Comma = ",",
semicolon = ";",
Tab = "\t"
),
selected = ";"
)
),
mainPanel(uiOutput("tb"))
)
))
)
)
SERVER CODE
server <- shinyServer(function(input,output){
data <- reactive({
file1 <- input$file
if(is.null(file1)){return()}
read.csv(file = file$datapath, sep=input$sep)
})
output$filedf <- renderTable({
if(is.null(data())){return()}
input$file
})
output$sum <- renderTable({
if(is.null(data())){return()}
summary(data())
})
output$table <- renderTable({
if(is.null(data())){return()}
data()
})
output$tb <- renderUI({
if(is.null(data())){return()}
tabPanel("About file", tableOutput("filedf")),tabPanel("Data", tableOutput("table")),tabPanel("Summary", tableOutput("sum"))
})
})
turns out there was a small typo in your code. You were referring to input$file and file$datapath, where that should have been input$file1 and file1$datapath. So a working version would be as shown below. Hope this helps!
library(shiny)
library(shinydashboard)
ui<-dashboardPage(
dashboardHeader(title = "Model"),
dashboardSidebar(
sidebarMenu(id="tabs",
menuItem("Data", tabName = "data", icon = icon("table"),startExpanded = TRUE,
menuSubItem("Load", tabName = "data1")
),
menuItem("Visualisation",icon=icon("bar-chart-o"), tabName = "vis"),
menuItem("Result", icon=icon("cog"), tabName = "result")
)
),
dashboardBody(
tags$style(type="text/css",
".shiny-output-error { visibility: hidden; }",
".shiny-output-error:before { visibility: hidden; }"
),
tabItems(
tabItem(tabName = "data1",
fluidPage(
fluidRow(
fileInput("file1","Choose CSV File",
accept = c("text/csv",
"text/comma-seperated-values, text/plain",
".csv")
),
tags$hr(),
checkboxInput("header", "Header", TRUE),
radioButtons("sep","Separator",
choices=c(Comma=",",
semicolon=";",
Tab="\t"),
selected = ";")
),
mainPanel(
uiOutput("tb")
)
)
)
)
)
)
server <- shinyServer(function(input,output){
data <- reactive({
file1 <- input$file1
if(is.null(file1)){return()}
read.csv(file = file1$datapath, sep=input$sep)
})
output$filedf <- renderTable({
if(is.null(data())){return()}
input$file1
})
output$sum <- renderTable({
if(is.null(data())){return()}
summary(data())
})
output$table <- renderTable({
if(is.null(data())){return()}
data()
})
output$tb <- renderUI({
if(is.null(data())){return()}
tabsetPanel(tabPanel("About file", tableOutput("filedf")),tabPanel("Data", tableOutput("table")),tabPanel("Summary", tableOutput("sum")))
})
})
shinyApp(ui,server)

Resources