For some reason suddenly my rmarkdown doesnt hide code anymore.
Even when I run the example in RStudio for a Rmarkdown sheet it doesnt show the output correctly.
Please find the example and output below:
> ---
> title: "Untitled"
> output: html_document
> date: "2024-09-23"
> ---
>
> ```{r setup, include=FALSE}
> knitr::opts_chunk$set(echo = TRUE)
> ```
>
> ## R Markdown
>
> This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
>
> When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
>
> ```{r cars}
> summary(cars)
> ```
>
> ## Including Plots
>
> You can also embed plots, for example:
>
> ```{r pressure, echo=FALSE}
> plot(pressure)
> ```
>
> Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
This is strange. I cannot reproduce it. Is it possible that you have something in your workspace that is interfering?
My copy of your code:
---
title: "Untitled"
output: html_document
date: "2024-09-23"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars}
summary(cars)
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
The way it is shown in your screenshot seems to indicate that something is not right in your source document and the code cells are not seen as code cells, or are just not knitted at all.
How do you render your document ? How to do you create the pdf ?
rmarkdown::render() should run your code cell to tranform them using knitr . From your screenshot, it seems like knitr has not run at all.
It is not that it is showing output code. It is showing the source document syntax, which means nothing except for knitr processing.
Okay thank you very much for your help.
I found another post online of someone having issues when not being inside a project. I dont quite understand it as well, but it worked (for now).