← Back to team overview

dhis2-users team mailing list archive

Re: DHIS2 Web API and R

 

Thank you for the share

I appreciate

Cordially

Thanks

On Wed, Oct 17, 2018, 10:17 Waka Wafubwa <charlwak@xxxxxxxxx> wrote:

> Hi All,
>
> I found an easier implementation of the example of using R with DHIS2. I
> found that *httr* library in R is easier and uses fewer lines of code to
> achieve the same.
>
> See below.
>
> #Library to use
> library(httr)
> #This is a URL endpoint for a report table which we can get from the WebAPI.
> myurl<-"https://play.dhis2.org/dev/api/reportTables/KJFbpIymTAo/data.csv";
>
> #Use httr to get the data from demo dhis2
> response<-GET(url=myurl, authenticate(user="admin", password="district"))
> #Here is the data
> mydata<-content(response, type="text/csv")
> head(mydata)
>
> Regards,
>
> Charles Waka
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-users
> Post to     : dhis2-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dhis2-users
> More help   : https://help.launchpad.net/ListHelp
>

References