Install ReporteRs from cran with the following command:
install.packages("ReporteRs")
Install developement version of ReporteRs from Github with the following command:
ReporteRs needs packages rvg and gdtools.
If you need to install them from source, you will need a cpp coompiler.** If have no idea what it means :
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 :).
Common errors are:
Loading required package: rJava
library(rJava)
Error : .onLoad failed in loadNamespace() for ‘rJava’, details:
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry
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:
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.
If you are on a mac, the most common issue with java is a newer version of java messed your setup.
From a terminal, run:
R CMD javareconf
Then reintall the package.
That is not a feature but this can be achieved by formating your text with pot objects.
library(ReporteRs)
# various text formatting properties we will use----
bold_text_prop <- chprop( base_text_prop,
font.weight = "bold", color = "red")
# concatenate chunk of formatted text -----
# replace whole paragraph by the previous object -----
template = file.path( system.file(package = "ReporteRs"),
"templates/bookmark_example.docx") )
target_file <- "replace_and_pot.docx" # file to produce
writeDoc(doc, target_file)
Download file replace_and_pot.docx - view with office web viewer
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 dimensionsoffx and offy that are the shape positions (left and top positions)Usually there is no need for managing par.properties 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), par.properties can be used to specify alignment of paragraphs.
library(ReporteRs)
doc <- pptx( )
offx = 3, offy = 5, width = 2, height = 1 )
target_file <- "par_and_par_props.pptx" # file to produce
writeDoc(doc, target_file)
Download file par_and_par_props.pptx - view with office web viewer