Run chunk repeatedly until error occurs

Hi,

in a code chunk I generate some random data. Rarely it happens that the random data are not okay and they create later an error in the chunk. So, I need to add some condition which prevents that these data are generated. For example:

x <- round(rnorm(6, mean=180, sd))
q <- quantile(x, c(0.25, 0.75))
# my code chunk broke later if q[1]==q[2] which happened not very often

Of course, I can copy the code chunk into an R file in a repeat {...} block to see what exactly leads to the error, but it would be easier if I could run the code chunk ntimes directly in the R Markdown file. Is this possible?

Sigbert

This topic was automatically closed 21 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.