1

I'm trying to build a webpage displaying a few graphs. I want to use R to build the graphs, and I want these graphs to automatically update themselves periodically. For example, a webpage showing a graph of the stock price of a particular company over time, which refreshes every day with new data.

what is the best way to approach this? Using Rook to run the R-scripts? can I use it along Markdown, for example, to make the html webpage? Or do you suggest something else?

user2037187
  • 75
  • 1
  • 6

1 Answers1

1

You can make your plots in a R file and write your webpage in markdown in which you call your R objects and plots. Alternatively you can also run the R code directly in the markdown file. With the knit2html function of the knitr package you can create the html page with the desired output. You can find basic examples on the knitr webpage.

You can schedule these file(s) on your own computer or on a server to update the data of the html output every day. If you have a machine that runs on Windows you can use the Windows Task Manager to run the batch file.

EDIT:

Here you can find a worked out example.

Jonas Tundo
  • 6,137
  • 2
  • 35
  • 45
  • I haven't worked with Windows Tasks Manager before and can't quite figure it out yet. I've made a *.bat file with the following lines: "C:\Program Files\R\R-2.15.3\bin\i386\Rgui.exe" R CMD BATCH "C:/../Rscript.R" R opens, but the code doesn't run. when I place it all on the same line, it gives me that it ignored 'R', 'CMD' and 'BATCH'. – user2037187 Apr 04 '13 at 17:07
  • Try "C:\Program Files\R\R-2.15.3\bin\R.exe" CMD BATCH "C:\..\Rscript.R" or "C:\Program Files\R\R-2.15.3\bin\Rscript.exe" "C:\..\Rscript.R" – Jonas Tundo Apr 04 '13 at 18:52
  • Thanks for your incredibly fast reply! But I can't get to work. each time, R does open, but the code doesn't run. i've read that for the R script, the destination must use forward slashes instead of backslashes. My result stays the same though: after R opens, nothing happens. – user2037187 Apr 04 '13 at 20:41
  • I use the Rscript.exe version most of the time and use backslashes for the destination file, it works just fine. Here is some other information about R in batch http://stackoverflow.com/questions/3412911/r-exe-rcmd-exe-rscript-exe-and-rterm-exe-whats-the-difference – Jonas Tundo Apr 05 '13 at 06:58