Download csv within r shiny app

179 views
Skip to first unread message

Sinead Bracken

unread,
Nov 9, 2017, 7:10:40 PM11/9/17
to Shiny - Web Framework for R

Hi Folks,

I would like to download a csv file from a bank website and plot each of the 400 expenditure columns in graphs in r shiny. The user should be able to select which of the 400 columns they wish to see on a plot and these plots should have the Date (the first column in the dataframe) on the x axis and the expenditure data on the y axis.



I have an r code to download the csv to a directory, unzip this file, open in r, and put the data into a dataframe.



I have the basic code for an r shiny app, obtained from here : https://rstudio.github.io/shinydashboard/get_started.html



My question is where can I put this r code I have to dowload the file into a dataframe, into the r shiny code?

does it go into the ui<-fluidpage section? or into the server<-function(input, output) section?

James Ferguson

unread,
Nov 10, 2017, 3:11:24 AM11/10/17
to Shiny - Web Framework for R
Hi Sinead

The way I look at this is a)

Does it involve what the user sees ? - Then UI eg UI to define a button that triggers a download selection, UI to display or select from what has been chosen 


b) Is it something that happens at start up (other than build the UI) or in response to user inputs  - then code probably belongs in serve

c) special case code that changes what the user sees in the UI then serevr updateXXX functions.

Best approach - start with a minimal app that displays a chart - eg work through a simple set up like https://shiny.rstudio.com/articles/build.html

Then adapt step by step - create an x-y chart from a dummy data set of your own, then add capability to download and buyild that dataset (hard coded) - the give user means to select what they download etc etc

Good lock !
Reply all
Reply to author
Forward
0 new messages