R in DHIS reports

It seems that the ‘Standard Report’ feature needs to be linked with JasperReports to work. Is this right? I try and create a new report without linking a file and it just doesn’t save and reloads the input screen rather than giving a ‘JasperReports XML file required’ error message so maybe I’m doing something wrong.

I’m a fan of R and thought this might be a very useful place to have the ability to input R code which produces reports. I can just output the data and create reports outside of the system, but it would be nice to incorporate it with the dashboard, etc. I’m not sure the best way for this to work, but it would be great for me if it did!

Thanks,

Tom

···

This message was scanned for viruses with Trend Micro ScanMail, GFI MailSecurity and GFI MailEssentials by the World Health Organization Regional Office for the Western Pacific. However, the recipient is advised to scan this e-mail and any attached files for viruses.

Disclaimer:

This e-mail, together with any attachments, is intended for the named recipients only and is confidential. It may also be privileged or otherwise protected by law.

If you have received it in error, please notify the sender immediately by reply e-mail and delete it and any attachments from your system. You may not copy or disclose its contents to anyone.

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. 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

···

On Mon, May 21, 2012 at 5:20 AM, hiattt@wpro.who.int wrote:

It seems that the ‘Standard Report’ feature needs to be linked with
JasperReports to work. Is this right? I try and create a new report without

linking a file and it just doesn’t save and reloads the input screen rather
than giving a ‘JasperReports XML file required’ error message so maybe I’m
doing something wrong.

I’m a fan of R and thought this might be a very useful place to have the
ability to input R code which produces reports. I can just output the data
and create reports outside of the system, but it would be nice to

incorporate it with the dashboard, etc. I’m not sure the best way for this
to work, but it would be great for me if it did!

Thanks,

Tom


This message was scanned for viruses with Trend Micro ScanMail, GFI
MailSecurity and GFI MailEssentials by the World Health Organization

Regional Office for the Western Pacific. However, the recipient is advised
to scan this e-mail and any attached files for viruses.

Disclaimer:

This e-mail, together with any attachments, is intended for the named

recipients only and is confidential. It may also be privileged or otherwise
protected by law.

If you have received it in error, please notify the sender immediately by
reply e-mail and delete it and any attachments from your system. You may not

copy or disclose its contents to anyone.


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp

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

···

On Mon, May 21, 2012 at 5:58 AM, Jason Pickering jason.p.pickering@gmail.com 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. 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