dhis2-users team mailing list archive
-
dhis2-users team
-
Mailing list archive
-
Message #01110
Re: R in DHIS reports
On Mon, May 21, 2012 at 5:58 AM, Jason Pickering <
jason.p.pickering@xxxxxxxxx> wrote:
> Hi Tom,
> Nice to hear others see the value in integrating DHIS2 and R more closely.
> I have added several examples recently to the DHIS2 documentation on how to
> use R and DHIS2/MyDatamart together. You can read this here.
>
> What I have yet to document (because I am still working on the code, then
> will include some documentation) is the use of FastRWeb<http://www.rforge.net/FastRWeb/>.
> FastRWeb basically allows you to execute R as CGI Scripts using Apache and
> Rserve. So a scripit like
>
> run<-function(n=10){
> x<-1:n
> y<-rnorm(n)
> Cairo(file="/tmp/svgtest.svg",type="svg",dpi=72)
> plot(x,y)
> dev.off()
> readLines("/tmp/svgtest.svg")
> }
>
> Is meant to produce a SVG graphic from some random data. Note that n=10.
> This will be used as a paramater in the URL
>
> So, something like
>
> http://mydhis.foo.com/cgi-bin/R/svg?n=100
>
> will tell FastRWeb to execute the file named svg.R (above) and supply the
> paramater n=100 to the script.
>
> This then would allow you to parameterize your R scripts, so that reports
> can be produced based on what the orgunit is. Now, does DHIS2 support this?
> Not yet, but I suspect that it could quite easily. However, Lars has added
> a number of examples of how to use the the WebAPI (which could also be used
> for reports) to the documentation, which could also be used for building
> reports with R.
>
> Hope this helps and keep me informed!
>
> Best regards,
> Jason
>
Hi Tom,
a quick way to get R reports into DHIS will be to use Jason's approach to
get the R reports online (available at a URL) - then create a "Resource" in
DHIS 2 which points to the URL for each report.
To create a resource go to "Reports" - "Resource" and select "External URL"
under type. Give a descriptive name and set the URL to the R report.
You can now add those reports to the dashboard - in dashboard module set
"Resources" in one of the link areas to the left.
Lars
References