Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Rmarkdown having a non working code, knit html output showing the errors and warnings

Lets say I have code in R which is not working, i.e. I run that code and get some errors and warnings, and I want to share the code and output showing errors and warnings, with the third person through R markdown.

Is it possible to knit R markdown if I have errors in r code chunks?, If yes, then is it going to show me waht errors and warnings occurs in the html output? Goal is to share the html output showing errors and everything with the non working code.

Any help on this is highly appreciated. Thanks.

like image 312
Sowmya S. Manian Avatar asked Sep 21 '16 18:09

Sowmya S. Manian


People also ask

How do I not show code output in R markdown?

include = FALSE prevents code and results from appearing in the finished file. R Markdown still runs the code in the chunk, and the results can be used by other chunks. echo = FALSE prevents code, but not the results from appearing in the finished file.

Why is my Rmarkdown file not knitting?

No Knit HTML button This means that RStudio doesn't understand your document is supposed to be an RMarkdown document, often because your file extension is . txt . To fix this, go to the Files tab (lower right corner, same pane as Plots and Help) and select the checkbox next to your document's name.

What output formats can be generate from R markdown?

There are two types of output formats in the rmarkdown package: documents, and presentations.

How do you show results in Rmarkdown?

To produce a complete report containing all text, code, and results, click “Knit” or press Cmd/Ctrl + Shift + K. You can also do this programmatically with rmarkdown::render("1-example. Rmd") . This will display the report in the viewer pane, and create a self-contained HTML file that you can share with others.


1 Answers

Yes, use knitr::opts_chunk$set(error = TRUE)

Here is the full markdown:

---
title: "Untitled"
date: "September 21, 2016"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, error = TRUE)
```

## R Markdown

Here is my error

```{r}
1 + 1
1 + "a"
```

Output:

Error

like image 122
Chris Avatar answered Sep 23 '22 05:09

Chris