davidgohel / ReporteRs

Note that ReporteRs has been removed from CRAN the 16th of July 2018 and is not maintained anymore. please migrate to officer.
244 stars 44 forks source link

Bookmarks are only detected in the first run of code #216

Closed drcarrot closed 7 years ago

drcarrot commented 7 years ago

Hello,

Firstly thank you for building ReporteRs, it is a great package! I am currently using ReporteRs to create a report for my institute, and the ability to use bookmarks is very important. I am running the scripts on a server, using a template with two bookmarks on the first page. When I restart my computer (but not necessarily the Rstudio session), the bookmarks are recognized, and the report's title and date appear. If I then modify the script downstream (i.e., change the size of a plot on another page) and rerun the code, the bookmarks are not recognized. If I restart the computer (but again, stay in the same Rstudio session), the bookmarks are recognized again.

The template (attached) has two bookmarks on the title page, and the scripts are as follows:

require (ReporteRs)
#read project info
form=read.table("test_form.txt", row.names=1, sep="\t", stringsAsFactors = FALSE)
doc=docx(template="report_template_empty.docx")

#Page 1
title_pot=pot(paste(form[1,]), textProperties(color = "white", font.family = "Georgia", font.size = 20 ))
date_pot=pot(paste(form[2,]), textProperties(color = "white", font.family = "Georgia", font.size = 16 ))
doc=addParagraph(doc,title_pot, bookmark="Title", par.properties= parProperties(text.align = "center"))
doc=addParagraph(doc,date_pot, bookmark="Date", par.properties= parProperties(text.align = "center"))

SESSION INFO report_template_empty.docx

R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.3 LTS

Matrix products: default
BLAS: /usr/lib/atlas-base/atlas/libblas.so.3.0
LAPACK: /usr/lib/atlas-base/atlas/liblapack.so.3.0

locale:
 [1] LC_CTYPE=en_US.UTF-8         
 [2] LC_NUMERIC=C                 
 [3] LC_TIME=en_US.UTF-8          
 [4] LC_COLLATE=en_US.UTF-8       
 [5] LC_MONETARY=en_US.UTF-8      
 [6] LC_MESSAGES=en_US.UTF-8      
 [7] LC_PAPER=en_US.UTF-8         
 [8] LC_NAME=en_US.UTF-8          
 [9] LC_ADDRESS=en_US.UTF-8       
[10] LC_TELEPHONE=en_US.UTF-8     
[11] LC_MEASUREMENT=en_US.UTF-8   
[12] LC_IDENTIFICATION=en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets 
[6] methods   base     

other attached packages:
 [1] dada2_1.4.0         Rcpp_0.12.12       
 [3] ReporteRs_0.8.8     ReporteRsjars_0.0.2
 [5] foreach_1.4.3       indicspecies_1.7.6 
 [7] picante_1.6-2       nlme_3.1-131       
 [9] ggdendro_0.1-20     gplots_3.0.1       
[11] dplyr_0.7.2         cowplot_0.7.0      
[13] vegan_2.4-3         lattice_0.20-35    
[15] permute_0.9-4       phyloseq_1.20.0    
[17] ape_4.1             reshape2_1.4.2     
[19] RColorBrewer_1.1-2  ggplot2_2.2.1      
[21] corrplot_0.77       psych_1.7.5        
[23] biomformat_1.4.0   

loaded via a namespace (and not attached):
 [1] bitops_1.0-6               matrixStats_0.52.2        
 [3] GenomeInfoDb_1.12.2        tools_3.4.1               
 [5] R6_2.2.2                   KernSmooth_2.23-15        
 [7] lazyeval_0.2.0             BiocGenerics_0.22.0       
 [9] mgcv_1.8-18                colorspace_1.3-2          
[11] ade4_1.7-6                 mnormt_1.5-5              
[13] compiler_3.4.1             Biobase_2.36.2            
[15] xml2_1.1.1                 DelayedArray_0.2.7        
[17] officer_0.1.5              caTools_1.17.1            
[19] scales_0.4.1               stringr_1.2.0             
[21] digest_0.6.12              Rsamtools_1.28.0          
[23] foreign_0.8-69             R.utils_2.5.0             
[25] XVector_0.16.0             base64enc_0.1-3           
[27] pkgconfig_2.0.1            htmltools_0.3.6           
[29] rvg_0.1.4                  rlang_0.1.2               
[31] shiny_1.0.4                bindr_0.1                 
[33] hwriter_1.3.2              jsonlite_1.5              
[35] BiocParallel_1.10.1        gtools_3.5.0              
[37] zip_1.0.0                  R.oo_1.21.0               
[39] RCurl_1.95-4.8             magrittr_1.5              
[41] GenomeInfoDbData_0.99.0    Matrix_1.2-10             
[43] munsell_0.4.3              S4Vectors_0.14.3          
[45] gdtools_0.1.5              R.methodsS3_1.7.1         
[47] stringi_1.1.5              MASS_7.3-47               
[49] SummarizedExperiment_1.6.3 zlibbioc_1.22.0           
[51] rhdf5_2.20.0               plyr_1.8.4                
[53] grid_3.4.1                 parallel_3.4.1            
[55] gdata_2.17.0               Biostrings_2.44.0         
[57] splines_3.4.1              multtest_2.32.0           
[59] knitr_1.17                 uuid_0.1-2                
[61] igraph_1.0.1               GenomicRanges_1.28.3      
[63] codetools_0.2-15           stats4_3.4.1              
[65] glue_1.1.1                 ShortRead_1.34.0          
[67] latticeExtra_0.6-28        data.table_1.10.4         
[69] RcppParallel_4.3.20        httpuv_1.3.5              
[71] png_0.1-7                  gtable_0.2.0              
[73] purrr_0.2.3                assertthat_0.2.0          
[75] mime_0.5                   xtable_1.8-2              
[77] survival_2.41-3            tibble_1.3.3              
[79] rJava_0.9-8                iterators_1.0.8           
[81] GenomicAlignments_1.12.1   IRanges_2.10.1            
[83] bindrcpp_0.2               cluster_2.0.6   
davidgohel commented 7 years ago

Hi,

Thanks. If possible, use package officer instead.

I tried to reproduce but could not.

require (ReporteRs)

doc=docx(template="report_template_empty.docx")

#Page 1
title_pot=pot("coco", textProperties(color = "white", font.family = "Georgia", font.size = 20 ))
date_pot=pot("icic", textProperties(color = "white", font.family = "Georgia", font.size = 16 ))
doc=addParagraph(doc,title_pot, bookmark="Title", par.properties= parProperties(text.align = "center"))
doc=addParagraph(doc,date_pot, bookmark="Date", par.properties= parProperties(text.align = "center"))

list_bookmarks(doc)
# [1] "Title" "Date"

# If I then modify the script downstream (i.e., change the size 
# of a plot on another page) and rerun the code
doc=addPlot(doc,fun = function() barplot( 1:6, col = 2:7))

list_bookmarks(doc)
# [1] "Title" "Date"
drcarrot commented 7 years ago

Thank you! Perhaps it is related to the fact that I am using Rstudio? I will try using officer instead!

Steph

On Thu, Aug 31, 2017 at 10:28 AM, David Gohel notifications@github.com wrote:

Hi,

Thanks. If possible, use package officer instead.

I tried to reproduce but could not.

require (ReporteRs)

doc=docx(template="report_template_empty.docx")

Page 1

title_pot=pot("coco", textProperties(color = "white", font.family = "Georgia", font.size = 20 )) date_pot=pot("icic", textProperties(color = "white", font.family = "Georgia", font.size = 16 )) doc=addParagraph(doc,title_pot, bookmark="Title", par.properties= parProperties(text.align = "center")) doc=addParagraph(doc,date_pot, bookmark="Date", par.properties= parProperties(text.align = "center"))

list_bookmarks(doc)

[1] "Title" "Date"

If I then modify the script downstream (i.e., change the size

of a plot on another page) and rerun the code

doc=addPlot(doc,fun = function() barplot( 1:6, col = 2:7))

list_bookmarks(doc)

[1] "Title" "Date"

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/davidgohel/ReporteRs/issues/216#issuecomment-326227222, or mute the thread https://github.com/notifications/unsubscribe-auth/AZracUiRqk9lZ6vhowImvqmINN4jOjuaks5sdm6agaJpZM4PIeDO .

davidgohel commented 7 years ago

No, I don't think it has anything to do with RStudio.

If possible, can you correct the script so that I am sure to be able to reproduce your case?

Thanks David