I am writing a server script of shiny where I want reactive() to first check the data on my c drive, if it's there then well and good else do the other data processing and save it for the next iteration. And the name of data is dependent on input$var
So that next time it will be really quick to create the charts
Following is just a running example of my big problem
library(shiny)
library(datasets)
library(ggplot2)
mt=mtcars
shinyServer(function(input, output) {
data1 =reactive({
if(file.exists("input$var.csv")
{data=read.csv(input$var.csv)})
else{
data=mt[mt$cyl==input$var,]
write.csv(data,file="c:\\input$var.csv")
}
})
output$Plot1 <- renderPlot({
data2=data1()
ggplot(data2$d,aes(x=gear,y=wt))+geom_boxplot() })
})
Aucun commentaire:
Enregistrer un commentaire