html_notebook error in Rmarkdown

Hi

I am experiencing that my notebook will suddenly convert code and output to the following, see the picture.

In general nothing has been done to the code chunk, but after a while a the chunk will convert to this.

The solution is to merely run the code again, and then the problem is solved.

Although as this is my notebook, the code is not always as structured as it would be in a report or etc. hence it is not always possible to run the notebook from one end to the other.

Has anyone had similar issues? Any tips to avoid this from happening?

My notebook as the following setup:


title: "Classification"
author: "Jonas R. Korsholm"
output:
html_notebook:
toc: true
toc_depth: 4
toc_float: true
number_sections: true
theme: readable
highlight: haddock
code_folding: show
fig_caption: yes

Can you share the version you are using of RStudio and rmarkdown ?

Also, do you have a Rmd document to share where you have this error ?

Either by joining a file or sharing the code here without screenshot and correctly formatted ?

Thank you for the quick reply!

I have the following RStudio version: Version 1.3.1073, "Giant Goldenrod" (718e6d75, 2020-07-29) for macOS

Where my Rmarkdown package is version 2.5

Here is an example of some code, where the output format yields an error. I have tried to attached the markdown file, although it does not appear to be possible, please let me know if I can do it in another way

library(ISLR)

Smarket <- Smarket
str(Smarket)

this is followed by the following in the preview and .nb.html file

<!-- rnb-source-end -->

<!-- rnb-output-begin eyJkYXRhIjoiJ2RhdGEuZnJhbWUnOlx0MTI1MCBvYnMuIG9mICA5IHZhcmlhYmxlczpcbiAkIFllYXIgICAgIDogbnVtICAyMDAxIDIwMDEgMjAwMSAyMDAxIDIwMDEgLi4uXG4gJCBMYWcxICAgICA6IG51bSAgMC4zODEgMC45NTkgMS4wMzIgLTAuNjIzIDAuNjE0IC4uLlxuICQgTGFnMiAgICAgOiBudW0gIC0wLjE5MiAwLjM4MSAwLjk1OSAxLjAzMiAtMC42MjMgLi4uXG4gJCBMYWczICAgICA6IG51bSAgLTIuNjI0IC0wLjE5MiAwLjM4MSAwLjk1OSAxLjAzMiAuLi5cbiAkIExhZzQgICAgIDogbnVtICAtMS4wNTUgLTIuNjI0IC0wLjE5MiAwLjM4MSAwLjk1OSAuLi5cbiAkIExhZzUgICAgIDogbnVtICA1LjAxIC0xLjA1NSAtMi42MjQgLTAuMTkyIDAuMzgxIC4uLlxuICQgVm9sdW1lICAgOiBudW0gIDEuMTkgMS4zIDEuNDEgMS4yOCAxLjIxIC4uLlxuICQgVG9kYXkgICAgOiBudW0gIDAuOTU5IDEuMDMyIC0wLjYyMyAwLjYxNCAwLjIxMyAuLi5cbiAkIERpcmVjdGlvbjogRmFjdG9yIHcvIDIgbGV2ZWxzIFxcRG93blxcLFxcVXBcXDogMiAyIDEgMiAyIDIgMSAyIDIgMiAuLi5cbiJ9 -->

another example: :slight_smile:

code chunk:

standardized.X <- scale(Caravan[,-86]) #Creates a standardized table, without the response varaiable

with the following output in the preview and .nb.html file

<!-- rnb-source-end -->

<!-- rnb-chunk-end -->


<!-- rnb-text-begin -->


We see, that the dataframe has 5822 observations and 86 predictors.

The response variable is 'Purchase'


<!-- rnb-text-end -->


<!-- rnb-chunk-begin -->


<!-- rnb-source-begin eyJkYXRhIjoiYGBgclxuYGBgclxudmFyKENhcmF2YW5bLDFdKVxuYGBgXG5gYGAifQ== -->

```r
```r
var(Caravan[,1])

Hi cderv

I think I have solved the issued.

Apparantly a space had sneaked its way in-between ``` and {r}, hence that yields the error.

Thus I think the problem is solved

1 Like

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.