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

Bookmark Text replacement using addPlot not working?And deleteBookmark also not working #165

Closed lrtai closed 7 years ago

lrtai commented 7 years ago

When I use addPlot to replace a bookmark PLOT with a ggplot, the bookmark is still in the docx after use writeDoc . I want to delete the bookmark PLOT after the plot is exactly inserted into the posiotion of PLOT ,but the function deleteBookmark is not working,and the error is NullPointerException.How can I solve this? Looking forward for the solution.

davidgohel commented 7 years ago

I can't reproduce the issue, so you are probably using an old version.

> library(ReporteRs)
> target_file <- tempfile(fileext = ".docx") 
> template <- system.file(package = "ReporteRs", "templates/bookmark_example.docx" ) # template example
> doc <- docx( template = template )
> doc <- addPlot( doc, fun = function() barplot( 1:6, col = 2:7) )
> list_bookmarks(doc)
[1] "PLOT"     "DATA"     "AUTHOR"   "REVIEWER"
> doc <- deleteBookmark(doc, "PLOT")
> list_bookmarks(doc)
[1] "DATA"     "AUTHOR"   "REVIEWER"
> 
lrtai commented 7 years ago

Dear, Thank you very much for your help!