Removing code chuck from PDF export using KNITR/Rmarkdown/Pandoc

LabKey Support Forum (Inactive)
Removing code chuck from PDF export using KNITR/Rmarkdown/Pandoc david beaumont  2016-10-20 11:55
Status: Closed
 
I am using Knitr/Rmarkdown/Pandoc/Miktex to create a PDF report.

My first script includes the markdown report, I then call it via another script and render it for export.
 
When creating the PDF my code doesn't show because I include {r echo=false} at the begging of all my code chunks but it appears the initial labkey code is displaying (see attached). How might I hide this from my export?

David
 
 
Jon (LabKey DevOps) responded:  2016-10-20 13:58
Hi David,

That's interesting to see the output of Rlabkey being seen in addition to the rendered results, despite you adding the echo=false option.

Let me get this looked at further. It may be that there needs to be another flag enabled.

Thanks for your patience.

Regards,

Jon
 
hilariagrieve responded:  2017-01-26 05:23
Hi, I have the same problem. How did you solve it? Thanks.
 
cnathe responded:  2017-01-26 07:53
The issue ended up being a problem in the LabKey server when there were multiple R scripts referencing each other (i.e. in that case the outer script's prolog was the one being displayed in the PDF report). There was an issue opened for release 16.3 for this issue and has since been resolved with r48647:
https://www.labkey.org/home/Developer/issues/issues-details.view?issueId=28946
-Cory
 
hilariagrieve responded:  2017-01-30 07:13
Hi Cory!
I am trying to convert my R report to a .docx file and have the same problem. My report begins like this...

---
title: "Reporte Final"
author: "hgrieve"
output:
  word_document: "Reporte Final Filiación.docx"
---

```{r setup, echo=FALSE, cache=TRUE, results='hide', warning=FALSE, comment=FALSE, warning=FALSE, message=FALSE, encoding = 'UTF-8',comments = ""}
knitr::opts_chunk$set(echo=FALSE, cache=TRUE, comment=FALSE, comments = "", warning=FALSE, eval = TRUE, encoding = "native.enc")
#knitr::opts_chunk$get();
knitr::pandoc('script.Rmd', format='docx')
```

and I get the docx file like the image I attached.
Can you help me? thanks!
 
cnathe responded:  2017-01-30 11:46
Are your R scripts being run as R Reports within your LabKey server, or are you running the R script on a separate session and reading data from your LabKey server? Also, what version of LabKey are you using? The fix for the original issue in the thread was checked in to the 16.3 release of LabKey server, so if your issue is the same, you would need to get the 16.3 release version later than r48647 to have the fix.
-Cory
 
hilariagrieve responded:  2017-01-31 05:10
Hi Cori, I am using the 16.2 version. So, I will upgrade labkey Server version and try again with this report.
But, my scripts is running like an R report with my Labkey Server. I select some data, make a table, and I am taking the data from this table to complete the R markdown-Pandoc report.

I need this report to generate a word document, so then it can be modified.

Thanks, I will comunicate if the new version doesn't solve my problem.

Hilaria
 
Jon (LabKey DevOps) responded:  2017-02-13 14:44
Hi Hilaria,

Let's separate this install problem from the rest of this thread. This will create less confusion.

Regards,

Jon