This is an example of how to use knitr for producing reports on data stored in Opal.
The requirement on client side is to have opal package installed:
install.packages('opalr', repos=c(getOption('repos'), 'https://cloud.r-project.org'), dependencies=TRUE)
The requirements on server side is:
The procedure is then the following:
Load the required libraries on client side and login in Opal (credentials and output are hidden)ā¦
Assign some variables into a data.frame with associated D symbol in R on Opal server side:
opal.assign(o,'D','FNAC.FNAC',variables=c('SVUOSI','SUKUP','PITUUS','PAINO'))
Preview the assigned data.frame:
opal.execute(o,'head(D)')
## SVUOSI SUKUP PITUUS PAINO
## 1090531236834569823 1978 2 1.745534 85.92770
## 1106599593314530568 1935 2 1.796389 104.89661
## 1123159255143935009 1946 2 1.549682 89.90047
## 1253779806594590726 1936 2 1.564716 92.87938
## 128078513779828327 1940 2 1.661319 66.83848
## 1389306377489410650 1959 1 1.517404 71.48879
Summary of the assigned data.frame:
opal.execute(o,'summary(D)')
## SVUOSI SUKUP PITUUS PAINO
## Min. :1933 1:1512 Min. :1.372 Min. : 40.10
## 1st Qu.:1944 2:1488 1st Qu.:1.624 1st Qu.: 67.08
## Median :1957 Median :1.683 Median : 77.40
## Mean :1957 Mean :1.684 Mean : 77.87
## 3rd Qu.:1970 3rd Qu.:1.747 3rd Qu.: 88.74
## Max. :1982 Max. :2.009 Max. :137.41
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.
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ā¦