File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Based on SO Question:
2
+ # https://stackoverflow.com/questions/78153629/static-version-of-r-shiny-app-using-shinylive-package-failing-to-preload-package
3
+
4
+ # Load required libraries
5
+ library(shiny )
6
+ library(shinythemes )
7
+
8
+ # Define UI
9
+ ui <- fluidPage(
10
+ theme = shinytheme(" flatly" ),
11
+
12
+ # App title
13
+ titlePanel(" CSV File Uploader" ),
14
+
15
+ # Sidebar layout with input and output definitions
16
+ sidebarLayout(
17
+ sidebarPanel(
18
+ fileInput(" file" , " Choose CSV File" , accept = " .csv" ),
19
+ tags $ hr(),
20
+ checkboxInput(" header" , " Header" , TRUE ),
21
+ checkboxInput(" stringAsFactors" , " Convert strings to factors" , TRUE )
22
+ ),
23
+
24
+ # Show CSV data
25
+ mainPanel(
26
+ tableOutput(" contents" )
27
+ )
28
+ )
29
+ )
30
+
31
+ # Define server logic
32
+ server <- function (input , output ) {
33
+
34
+ # Read CSV file
35
+ data <- reactive({
36
+ req(input $ file )
37
+ df <- read.csv(input $ file $ datapath ,
38
+ header = input $ header ,
39
+ stringsAsFactors = input $ stringAsFactors )
40
+ return (df )
41
+ })
42
+
43
+ # Show CSV data
44
+ output $ contents <- renderTable({
45
+ data()
46
+ })
47
+ }
48
+
49
+ # Run the application
50
+ shinyApp(ui = ui , server = server )
You can’t perform that action at this time.
0 commit comments