Sink is full when calling rmarkdown::render
Asked Answered
W

1

8

I'm following this short tutorial to print my R script directly as an HTML document. It should be pretty straightforward. With a few small changes to the header and comments of an otherwise normal R script, calling the command rmarkdown::render('/Users/you/Documents/yourscript.R') at the end of an R script should call the knitr::spin function to go from my R script to an Rmd file to the final HTML or PDF.

I'm getting the error: Error in sink(con, split = debug) : sink stack is full and I'm not sure what to do. All solutions I've found online point out that one needs to close sink()'s after opening them. But since I'm not really using sink() myself, I don't see how or where I should close them.

I'm using R 3.3.0.

This Question asks the same but is downvoted and has no answers.

Woodhouse answered 19/7, 2016 at 10:18 Comment(0)
W
17

Well, it turned out I was doing something stupid: I included the command rmarkdown::render('/Users/you/Documents/yourscript.R') within my script and forgot to comment it out. I probably ended doing an infinite recursion. I commented that line out and it worked beautifully.

Woodhouse answered 21/7, 2016 at 11:48 Comment(1)
FYI, if you want to include the rmarkdown::render() command in a chunk in the doc itself so you can easily run it and knit to all formats, just put the chunk option eval=FALSE in the chunk header. This way it won't recursively run that command when knitting the doc itself.Subaqueous

© 2022 - 2024 — McMap. All rights reserved.