-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.R
51 lines (42 loc) · 1.23 KB
/
app.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Based on SO Question:
# https://stackoverflow.com/questions/78160039/using-shinylive-to-allow-deployment-of-r-shiny-apps-from-a-static-webserver-yiel
# Load required libraries
library(shiny)
library(shinythemes)
# Define UI
ui <- fluidPage(
theme = shinytheme("flatly"),
# App title
titlePanel("CSV File Uploader"),
# Sidebar layout with input and output definitions
sidebarLayout(
sidebarPanel(
fileInput("file", "Choose CSV File", accept = ".csv"),
tags$hr(),
checkboxInput("header", "Header", TRUE),
checkboxInput("stringAsFactors", "Convert strings to factors", TRUE),
tags$a("See source on GitHub!", href = "https://github.com/coatless-tutorials/convert-shiny-app-r-shinylive", target="_blank")
),
# Show CSV data
mainPanel(
tableOutput("contents")
)
)
)
# Define server logic
server <- function(input, output) {
# Read CSV file
data <- reactive({
req(input$file)
df <- read.csv(input$file$datapath,
header = input$header,
stringsAsFactors = input$stringAsFactors)
return(df)
})
# Show CSV data
output$contents <- renderTable({
data()
})
}
# Run the application
shinyApp(ui = ui, server = server)