Skip to content
This repository has been archived by the owner on Feb 13, 2020. It is now read-only.

Knitting with errors #531

Open
Caroline-Seip opened this issue Nov 9, 2018 · 1 comment
Open

Knitting with errors #531

Caroline-Seip opened this issue Nov 9, 2018 · 1 comment

Comments

@Caroline-Seip
Copy link

Caroline-Seip commented Nov 9, 2018

For anyone who's had problems knitting their RMarkdown files with intentional errors, you can either put {r error=TRUE} at the top of the code chunk you want to accept an error in, or

To accept errors throughout the entire document put
{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, error = TRUE)

As a code chunk at the top of the file. This code chunk automatically comes up when you make a new RMarkdown file, just need to add the error=TRUE part

Shoutout to @ChadFibke and @j-schaub for helping me out with this one

@vincenzocoia
Copy link
Member

You can also use the try() function. Here's sample code:

res <- try(log("hi"))
if (inherits(res, "try-error")){
     print("res resulted in an error!")
} 

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants