I am trying to generate a pie chart on my browser using rApache
my R code is this
library(MASS)
school = painters$School
school.freq = table(school)
pie(school.freq)
when i run this on browser ... i am getting this error
rApache has something to tell you. View source and read the HTML comments at the end.
Error in function (file = ifelse(onefile, "Rplots.pdf", "Rplot%03d.pdf"), : cannot open file 'Rplots.pdf'
any idea why i am getting this error?
pie() and other plotting commands will try to write to a PDF by default. If you want to display an image in a web page using RApache, then this approach is not what you want. You have to tell RApache what you want it to do.
Look in the test directory which was created when you unpacked the RApache source code. There, you will find several scripts which illustrate how to render a PNG image on the web page. For example in sendBin.R, you will find this code:
If you replace the line plot(rnorm(10)) with your pie(school.freq), then save this file in the right place (e.g. /var/www/R/plot.R), your chart should appear on the web page.
Make sure you read the RApache documentation and configure it so as R scripts can be run from locations in your web root.