Opal Reporting with R

This is an example of how to use knitr for producing reports on data stored in Opal.

Procedure

The requirement on client side is to have opal package installed:

install.packages('opalr', repos=c(getOption('repos'), 'https://cloud.obiba.org'), dependencies=TRUE)

The requirements on server side is:

alt text

The procedure is then the following:

Example

Load the required libraries on client side and login in Opal (credentials and output are hidden)...

library(opalr)
o <- opal.login('administrator', 'password', 'https://opal-demo.obiba.org')

Assign some variables into a data.frame with associated D symbol in R on Opal server side:

opal.assign(o,'D','mica_demo.FNAC',variables=c('SVUOSI','SUKUP','PITUUS','PAINO'))

Preview the assigned data.frame:

opal.execute(o,'head(D)')

Summary of the assigned data.frame:

opal.execute(o,'summary(D)')

Histogram figure of the PITUUS variable:

plot(opal.execute(o,'hist(D$PITUUS)'))

Loading ggplot2 library in R on Opal server side... This will fail if ggplot2 is not installed in R server environment.

opal.execute(o, 'library(ggplot2)')

Plot PITUUS vs. PAINO with "lm" smoothing:

opal.execute(o,'qplot(PITUUS,PAINO, data=D) + geom_smooth(method="lm")')

Cleaning the resources on Opal server side...

opal.logout(o)


Try the opalr package in your browser

Any scripts or data that you put into this service are public.

opalr documentation built on Sept. 18, 2024, 9:11 a.m.