Different output for Notebook and knitted html (flexdashboard, tabset)

rmarkdown

#1

I have written a report.
Gives me the number of patients , operations etc for all departments of the hospital. CSV file is read and several "simple" grouping and summarizing operations using dplyr are done.
Output is produced with ggplot and ggtexttable
If I run the entire notebook, all output tables and plots are o.k. within the notebook.

If I knit the notebook to html I have a loss of data in the output, lower bars in the graph, and mistakes in the tables( lower calculated values). The values of the sum for different departments are too low.
I had the same problem when I did the reporting of February and used flexdashboard. When I used {.tabset} instead of flexdashboard I got correct output in notebook and .html.
Now when I prepare the march reporting I got similar issue, but this time I used {.tabset} output in advance and ran in the same issues as last time.

I use Rstudio 1.1.383 all libraries are unto date. R: 3.4.3

Reproducible example is very complicated, as the data contain patient information

Any ideas ?

Thanks Peter


#2

First of all, I've never came across such an issue. Nevertheless, I understand that, of course, you shouldn't post PII of your patients, but I'm fairly confident that this issue has little to do with actual PII. So maybe you can localize it to a small subset of random data that will demonstrate your problem.

One possible explanation is that any report generated in markdown will start from clean session and maybe you have some data in global environment while working in interactive notebook. This data can interfere with what you see on the screen and in knitted report.


#3

I agree with @mishabalyasin, it sounds like your interactive session has variables or packages pre-loaded that are masking your issue when running the chunks. I would suggest to restart your R session, and clean your environment variables before trying to run the code chunks.


#4

Thanks to both .
Run the knit notebook on a different computer directly after reboot of Rstudio.
Now the results are correct.
What's the best way to avoid such problems ?
Peter