Install ReporteRs from cran with the following command:


Install developement version of ReporteRs from Github with the following command:



ReporteRs needs packages rvg and gdtools.

This requires a cpp coompiler. If have no idea what it means :

  • you’re using R for Windows, install Rtools
  • you’re using R for Mac, install Xcode
  • you’re using R for Linux, you should manage on your own!

Something screwed up

Could not find build tools

If you get an error during this step saying Error: Could not find build tools necessary to build XXX, you are probably installing the package from source (and rebuilding also rvg or gdtools), best advice is to read again that part :).

rJava hell

Common errors are:

  • JAVA_HOME cannot be determined from the Registry
Loading required package: rJava
Error : .onLoad failed in loadNamespace() for ‘rJava’, details:
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry
  • unable to load shared object […] rJava.dll
Error : .onLoad failed in loadNamespace() for 'rJava', details:
  call: inDL(x, as.logical(local), as.logical(now), ...)
  error: unable to load shared object '[...]/rJava/libs/x64/rJava.dll':
  LoadLibrary failure:  %1 is not a valid Win32 application.

Error: package/namespace load failed for 'rJava'

Most of the time, it comes from a bad java installation on your Windows machine:

  • you are running R 64 bits but you have installed java 32 bits
  • you are running R 32 bits but you have installed java 64 bits

Solution is to install the java version corresponding to your R version. I found that post very usefull:

I have a Windows 64 bits, I installed java 32 bits and java 64 bits. When I install ReporteRs, I don’t meet any trouble.

If you are on a Windows machine and (for any reason) you can only have one java version (32 or 64 bits), install the package with the following option :

install.packages("ReporteRs", INSTALL_opts = "--no-multiarch")
install_github("davidgohel/ReporteRs", args = "--no-multiarch")

Some solutions on Stackoverflow involve to set environment variable JAVA_HOME. I never had to use that but it seems a valid solution for some configurations.

Word: replace only a word in a paragraph

That is not a feature but this can be achieved by formating your text with pot objects.


# various text formatting properties we will use----
base_text_prop <- textProperties( = "Arial")
bold_text_prop <- chprop( base_text_prop, 
                          font.weight = "bold", color = "red")
italic_text_prop <- chprop( base_text_prop, = "italic")

# concatenate chunk of formatted text -----
your_pot <- pot("This is a pot ", format = base_text_prop) + 
  pot( "with italic text", format = italic_text_prop) + 
  pot( " and red bold", format = bold_text_prop)

# replace whole paragraph by the previous object -----
doc <- docx( title = "My example",
            template = file.path( system.file(package = "ReporteRs"),
                                  "templates/bookmark_example.docx") ) 

doc <- addParagraph(doc, your_pot, bookmark = "REVIEWER" )
target_file <- "replace_and_pot.docx" # file to produce 
writeDoc(doc, target_file)

PowerPoint: offx, offy, width and height

You may want to arrange plot, tables or paragraphs freely on a slide - without mapping content to a layout defined in the slide master layouts.

In this case, usage of some parameters is becoming mandatory. You will need to specify:

  • width and height that are the shape dimensions
  • arguments offx and offy that are the shape positions (left and top positions)

PowerPoint and

Usually there is no need for managing when adding content in a slide: i.e. graphics and tables cannot be associated with center or padding properties. Paragraphs can.

When formatting properties of paragraphs don’t inherit from the template (when adding a pot or a set_of_paragraphs), can be used to specify alignment of paragraphs.


doc <- pptx( )
doc <- addSlide( doc, slide.layout = "Title and Content" )

doc <- addParagraph( = parCenter(),
    doc = doc, value = pot("this is a pot", textBold(color = "red")), 
    offx = 3, offy = 5, width = 2, height = 1 )

target_file <- "par_and_par_props.pptx" # file to produce 
writeDoc(doc, target_file)