1 Description

This vignettes will guide the user in the exploration of the functionalities of easyreporting.

2 Requirements

For the usage you just need to load the easyreporting package, which will load the R6 and rmarkdown packages.

if(!requireNamespace("BiocManager", quietly = TRUE))

3 easyreporting instance creation

For simplicity we setup a project directory path starting from the working directory for our report, but you can just enter any path. The filenamepath and the title parameters are mandatory, while the author(s) paramenter is optional.

Once created the easyreporting class instance, we can use it in our further code to make other operations. It stores some variables for us, in order to not be called again during next opreations. For example the name and the path of the report, the type of report and the general rmarkdown options of the document.

proj.path <- file.path(tempdir(), "general_report")

er <- easyreporting(filenamePath=proj.path, title="example_report",
                      person(given="Dario", family="Righelli", 
                                    affiliation="Institute of Applied Mathematics, CNR, Naples, IT", 
                    person(given="Claudia", family="Angelini",
                              affiliation="Institute of Applied Mathematics, CNR, Naples, IT",

er <- easyreporting(filenamePath=proj.path, title="example_report",
                        author=c("Dario Righelli"))

4 Code Chunks

Easyreporting enables to include rmarkdown titles from first (default) to sixth level. The good norm, when writing reports, is always to add a title to a new code chunk (CC) followed by a natural language text, which describes the CC.

mkdTitle(er, title="Code Chunks", level=1)

mkdGeneralMsg(er, "A simple paragraph useful to describe my code chunk...")

4.1 Manually creating a code chunk

The most mechanical way to create and populate a CC is to manually open the CC, to insert the code, and then to close it. Here we show how to insert a variable assignenent inside a CC.

mkdTitle(er, title="Manual code chunk", level=2)

#> Please remember to close the Code Chunk!
#> Just invoke mkdCodeChunkEnd() once you complete your function calling :)
variable <- 1
mkdVariableAssignment(er, "variable", `variable`, show=TRUE)

4.2 Code Chunks Options

By using the standard function makeOptionsList, it is possible to create a custom list of options (an optionsList), as described from rmarkdown. In this way we are able to personalize even single code chunks, depending on specific cases.

Here we create an optionsList where the includeFlag is set to TRUE (our default is FALSE).

When opening the code chunk, it is possible to pass the new optionsList to the easyreporting class mkdCodeChunkSt method.

optList <- makeOptionsList(echoFlag=TRUE, includeFlag=TRUE)
mkdCodeChunkSt(er, optionList=optList)
#> Please remember to close the Code Chunk!
#> Just invoke mkdCodeChunkEnd() once you complete your function calling :)

4.3 Adding personal files to source

If you have one or more files with some functions that you want to use inside your code, it is possible to add them by using the sourceFilesList parameter.

## moreover I can add a list of files to source in che code chunk
RFilesList <- list.files(system.file("script", package="easyreporting"), 
mkdCodeChunkSt(er, optionList=optList, sourceFilesList=RFilesList)
#> Copying /tmp/RtmpPOITUa/Rinst306dec3d301c8e/easyreporting/script/fakeFunctions.R to /tmp/Rtmp19w2js//fakeFunctions.R
#> Copying /tmp/RtmpPOITUa/Rinst306dec3d301c8e/easyreporting/script/geneFunctions.R to /tmp/Rtmp19w2js//geneFunctions.R
#> Copying /tmp/RtmpPOITUa/Rinst306dec3d301c8e/easyreporting/script/importFunctions.R to /tmp/Rtmp19w2js//importFunctions.R
#> Copying /tmp/RtmpPOITUa/Rinst306dec3d301c8e/easyreporting/script/plotFunctions.R to /tmp/Rtmp19w2js//plotFunctions.R
#> Please remember to close the Code Chunk!
#> Just invoke mkdCodeChunkEnd() once you complete your function calling :)
mkdGeneralMsg(er, message="(v <- fakeFunction(10))")

4.4 Complete chunk creation

It is also possible to create a complete chunk by using the mkdCodeChunkComplete function.

mkdCodeChunkComplete(er, code="v <- fakeFunction(11)")

Finally, it is possible to create a unique code chunk within all the functionalities desribed before.

optList <- makeOptionsList(includeFlag=TRUE, cacheFlag=TRUE)

                comment="This is the comment of the following code chunk",
                code="v <- fakeFunction(12)",

5 Compiling the report

Once finished our analysis it is possible to compile the produced rmarkdown report simply by using the compile method. The compile method appends a sessionInfo() to the report to trace all the packages and versions used for the analysis.


6 Session Info

#> R version 4.1.0 (2021-05-18)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 20.04.2 LTS
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.13-bioc/R/lib/
#> LAPACK: /home/biocbuild/bbs-3.13-bioc/R/lib/
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_GB              LC_COLLATE=C              
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> other attached packages:
#> [1] distill_1.2         easyreporting_1.4.0 BiocStyle_2.20.0   
#> loaded via a namespace (and not attached):
#>  [1] bookdown_0.22       digest_0.6.27       R6_2.5.0           
#>  [4] jsonlite_1.7.2      formatR_1.9         magrittr_2.0.1     
#>  [7] evaluate_0.14       stringi_1.6.2       rlang_0.4.11       
#> [10] jquerylib_0.1.4     bslib_0.2.5.1       rmarkdown_2.8      
#> [13] tools_4.1.0         stringr_1.4.0       xfun_0.23          
#> [16] yaml_2.2.1          compiler_4.1.0      BiocManager_1.30.15
#> [19] htmltools_0.5.1.1   downlit_0.2.1       knitr_1.33         
#> [22] sass_0.4.0