R package ReporteRs for generating reports with R (e.g. PPTX files)

Hi all

I use the R package ReporteRs from https://github.com/davidgohel/ReporteRs to generate Powerpoint reports. This works also in KNIME by using the R Interactive integration within KNIME. I use the Table to R and Add Table to R nodes to collected my tables and then generate the Powerpoint slides in a R to Table node. See example code below. 

My questions are:

1) How can I do similar things with images ? That means: Read an Image in KNIME, transfer it to the R world and use this image in an R script!

2) The R to Table node expects an output dataframe  like knime.out. I use the assignment of such an output just as a dummy information that is not really needed (see last row of example code). Is there is more elegant way ?


Best, Frank


# Load library

##### load template
doc = pptx(template = 'C:/Knime_Archive/template.pptx')

##### add Title Slide
doc = addSlide( doc, slide.layout = 'Title' )
doc = addTitle( doc = doc, value = "Report Test")

#### boring slide
doc = addSlide( doc, slide.layout = "Two columns")
doc = addTitle( doc = doc, value = "Boring slide")

#### exciting slide
doc = addSlide( doc, slide.layout = "Two columns")
doc = addTitle( doc = doc, value = "Exciting slide")
report.table1 <- rframe
report.table2 <- rframe2
doc = addFlexTable( doc, vanilla.table(report.table1[1:2,1:2]))
doc = addFlexTable( doc, vanilla.table(report.table2[1:2,1:2]))

# Write file
writeDoc( doc, file = "C:/Knime_Archive/demo_knime_r2.pptx" )

knime.out <- rframe+rframe2

Hi Frank, sorry to hijack your topic but i also am looking into using this package within Knime. When i run the code in R studio all works fine, however if i do the same from within Knime i get this error message:

Loading required package: ReporteRsjars
Error : .onLoad failed in loadNamespace() for 'ReporteRsjars', details:
  call: .jinit()
  error: Unable to create a Java class loader.
In addition: Warning messages:
1: package 'ReporteRs' was built under R version 3.1.3 
2: package 'ReporteRsjars' was built under R version 3.1.3 
3: In .jinit() : Cannot set VM parameters, because VM is running already.
Error: package 'ReporteRsjars' could not be loaded

Any idea what could be causing this and how to fix it? Did you do anything special to get this package to work? I've used R to create ggplot images from within Knime and it always worked, expect for ReporteRs that is.

Help would be appreciated!

Hi Frank,

To answer your question, i think if you create your images in ggplot in R you would be able to add them to the powerpoint easily by just adding them to the R script. 

At least that is my plan going forward. I have already created the images in ggplot and am now looking into a way to generate a powerpoint and word document with these images.



The setup via KNIME requires the following packages for ReporteRs: rJava, ggplot2. ReporteRsjars (See: https://github.com/davidgohel/ReporteRs) Maybe this has to do with your error message. Can you check if all packages are available under R?

RE. IMAGES: My "problem" is a bit different. I already have images in the KNIME workflow that I want to hand over to a "R node".


Best, Frank



Indeed i think not all the packages were up to date. Now i've managed to get it working. I am not completely sure how you can tackle your problem. I dont think you can hand over images to the R node, only generate them there yourself in a plot or by picking them up from a folder somewhere. 

Have you already tried to write the images to a folder earlier in the workflow and pick them up later when you run ReportRs? That could be a solution i think.




Yes, good idea, storing the image files in a temporary folder makes sense for the meantime, but it is just a workaround.

KNIMErs, please consider to establish an R node that has an image port as one (of  two) input port(s).


Have a nice weekend,