Created
September 10, 2013 19:25
-
-
Save stla/6514319 to your computer and use it in GitHub Desktop.
How to use renderChart2() when the data file has not been uploaded yet ?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(rCharts) | |
library(data.table) | |
#### | |
#### Server | |
#### | |
shinyServer(function(input, output) { | |
## | |
## load data csv file | |
## | |
fileInput <- reactive( { | |
if (is.null(input$files)){ # User has not uploaded a file yet | |
return(NULL) | |
} | |
input$files | |
}) | |
## | |
## output message : file loaded | |
## | |
output$loaded <- reactive({ | |
if (is.null(input$files)){ # User has not uploaded a file yet | |
return("no file loaded yet") | |
} | |
"" | |
}) | |
## | |
## read data file | |
## | |
dataInput <- reactive({ | |
if (is.null(input$files)){ # User has not uploaded a file yet | |
return(NULL) # WHAT COULD WE PUT HERE ??? | |
} | |
inFile <- input$files | |
read.csv(inFile$datapath, header=T) | |
}) | |
## | |
## output: print contents of loaded file | |
## | |
output$dat <- renderChart2({ | |
dTable(dataInput()) | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(rCharts) | |
library(data.table) | |
#### | |
#### UI | |
#### | |
shinyUI(pageWithSidebar( | |
headerPanel("SAP import"), | |
## | |
## sidebar panel | |
## | |
sidebarPanel( | |
fileInput("files", "File data", multiple=FALSE) | |
), | |
## | |
## main panel | |
## | |
mainPanel( | |
tabsetPanel( | |
tabPanel("Data", | |
textOutput("loaded"), | |
br(), | |
chartOutput("dat", 'datatables') | |
) | |
),id="idtab" | |
) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment