1

I have a big problem since a long time and I could not find any solution. Daily, I waste a lot of time because of it.

I use knitr_1.29 to generate HTML reports (R version 4.0.0, R Studio 1.3.959). Sometimes the output of one or several chunks is not printed whitout any reason.

I mainly meet this problem with the "pheatmap" and "kable" functions.

An example: I have very similar chunks (same options, same kind of output) in my Rmd file and... some outputs are printed, some others not ! Or I will execute knitr on the same .RMD file twice: the first time, the output will be printed, the second one, it will not. This happens even if I changed nothing in my .Rmd file.

I have this problem when I use "render" or when I "knitr" directly the document...

Thank you very much for your help... I'm desesperate...

EDIT : a sort of example... But actually, with this kind of simple file, I will not meet any problem. The problem seems to occur with long and complicated files...

---
title: "Title"  
subtitle: 'Subtitle'
author: "me"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
  html_document:  
    toc: true
    toc_depth: 4
    toc_float: true
    code_folding: hide    
    theme: flatly
    highlight: tango
---

<style type="text/css">

body{ /* Normal  */
      font-size: 16px;
  }
td {  /* Table  */
  font-size: 14px;
}
h1.title {
  font-size: 60px;
  color: Tomato;
}
h1 { /* Header 1 */
  font-size: 28px;
  color: SteelBlue;
}
h2 { /* Header 2 */
    font-size: 22px;
  color: SteelBlue;
}
h3 { /* Header 3 */
  font-size: 18px;
  color: SteelBlue;
}
code.r{ /* Code block */
    font-size: 12px;
}
pre { /* Code block - determines code spacing between lines */
    font-size: 14px;
}
</style>



```{r global_options,message=FALSE,results="hide"}
knitr::opts_chunk$set(fig.align="center",eval.after="fig.cap",
                      fig.width=12,fig.height=5,
                      warning=FALSE, 
                      results="asis",
                      message=FALSE)


```

```{r setup, results="hide",fig.keep="none"}
library(DESeq2)
library(edgeR)
library(ade4)
library(factoextra)
library(kableExtra)
library(RColorBrewer)
library(vsn)
library(ggVennDiagram)
library(wesanderson)
library(DescTools)
library(pheatmap)
library(WGCNA)
library(readxl)
library(gage)
library(sva)
library(gageData)
library(AnnotationDbi)
library(org.Hs.eg.db)
library(SummarizedExperiment)
library(ggrepel)
library(openxlsx) 
library(ggrastr)
library(viridis)


```


This chunk will print nothing 
```{r,fig.height=7}
matrix1 = matrix(rnorm(200), 20, 10)
pheatmap(matrix1, color=inferno(100))



``` 

This chunk will print something

```{r heatmap C2 in C1 TEST,fig.height=10}
matrix2 = matrix(rnorm(200), 20, 10)
pheatmap(matrix2, color=inferno(100))


``` 





This chunk will print nothing
```{r model 1}
t<-sample(1:2,1)

if(t==1) {
df<-data.frame(replicate(3,sample(0:1,5,rep=TRUE)))

kable(df) %>%kable_styling("striped")
}
```


This chunk will print a table.
```{r model 2}
if(t==1) {
df<-data.frame(replicate(3,sample(0:1,5,rep=TRUE)))

kable(df) %>%kable_styling("striped")
}
```
Nin00
  • 11
  • 2
  • Can you make a reproducible example that will show the problem? Maybe make `echo` explicit in the chunks – csgroen Sep 03 '20 at 12:29
  • 1
    Hi, I added a kind of reproductible example, but I'm not sure it will help as my problem is not "reproductible" (sometimes it works, sometimes not...) Unfortunately, "echo=TRUE" did not help. – Nin00 Sep 03 '20 at 12:49
  • I made a more minimal example from your example and knit a few times... all times were successful. Not sure what's going on. Have you tried reinstalling knitr? – csgroen Sep 03 '20 at 13:55
  • Thank you for having tried. No, I did not try to reinstall knitr. I will see if it solves my problem. – Nin00 Sep 04 '20 at 06:52

0 Answers0