Rmarkdown: html output is missing chunks

Hey all,

I have to do the same code 3 times and knit a html for the output.
The code is running in R and gives the expected tables and plots.
R output is saved into a .rda file: save(all parameters, file = "file.rda")
I open my .rmd file and start with:

title: "title"
author: "name"
date: "2/18/2021"
output: html_document

Now comes a list of chunks for the first one (SMDH) of three repeats, which are SMDH, MD and ROM.
Preknitting works nicely. knit shows the first problem:

{r table2H, echo = FALSE, results = 'asis'}
{r table2W, echo=FALSE, result = 'asis'}

The first chunk is knitted, the second not.
When I delete result = 'asis' then the second chunk is knitted, too.
When I put the r table2W chunk in the first place, then this one is knitted, but the second one r table2H is not.

Now I copy the whole code and only change the names of the chunks and desired tables for the 2. round = MD. Preknitting shows everything nicely. knit shows only the first SMDH, but won't show the MD group of chunks at all. Nothing.

Now I copy again and change names of chunks and tables for the third round = ROM. Preknitting is fine.
knit shows now the first SMDH and third ROM, but not the second group.

Knitting shows:

  1. SMDH, fine
  2. MD nothing
  3. ROM fine
    The code is every time the same, only the parameters change.

I tried to re-order the 3 parts and found out, that the one in the middle will never show, regardless which part it is:

  1. SMDH fine
  2. ROM nothing
  3. MD fine

I got one warning:
***[WARNING] Could not parse YAML metadata at line 130 column 1: :6:0: Unexpected ''*** But in my code is no unexpected '' in line 130 - I checked and redid this line like 100times. And I have no idea about how to access YAML metadata (what is it?!) to remove the unexpected '`'.

That leaves me a little bit helpless.
Does anyone of you have any ideas about how to solve this issue?
I can provide the whole code as well, but it is a bit long, I suppose...

I'm not fully following all of your troubleshooting, and this might not be it (except some of your swapping of the code seems like it might be related), but your second chunk has result = 'asis' (singular "result") rather than results = 'asis' (plural "results"). Since you noted it worked when you deleted the (invalid) result = 'asis', I wonder if that might be related?

Also, with RMarkdown the row numbers of errors can be really confusing. That seldom is actually calling out the row number in the .Rmd file. So, the "line 130" is likely not actually line 130.

Thank you so much for your answer!

I redid the code completely, but ran again into the same problem again, that the chunks are not completely converted into .html.

  1. chunk = table

  2. chunk = graph

  3. chunk = table

  4. chunk = graph

  5. chunk = table

  6. chunk = graph


  1. chunk = table

  2. chunk = graph

  3. chunk = table

  4. chunk = graph

  5. and 3. graph is missing.
    When I separate the chunks and make a new .html for each pair of chunks, then it works perfectly fine.
    Yes, all chunks have different names.
    But afterwards I have to merge the documents.

code for table and graph of which the first chunk is knitted, the second one not:

{r table2H, echo = FALSE, results = 'asis'}
{r, figuresS, echo = FALSE, fig.show="hold", out.width="30%"}
par(mar = c(4, 4, .1, .1))

That is baffling. If the whole doc knits pretty quickly, maybe try just making {r} the header for each chunk—with no names and no settings. Knit and see if the issue still exists (the code will show up, of course, but that's just trying to get to a working base). If that works and there is some output, then you can start adding in chunk options one at a time to see if something breaks along the way.

Chunks don't have to be named (it's useful if there are dozens of them because then, if the knitting breaks, you'll get a chunk name as to where it happened). And, if you add library(knitr), you may want to use kable(tableS2) to get a nicer looking table and not need results = 'asis' for those chunks.

All this is to say: this sounds really weird!

Thank you so much, I will try that!

With this specific table kable was not working. Warning ***error in as.data.frame.default(x) : cannot coerce class 'c("ram.uni", "ram")' to a data.frame ***
That's why I don't use kablehere.