Even years later, when you’ve completely forgotten what you did, the whole write-up, every single number or pixel in a plot is reproducible. The numbers and graphics you report are actually what they are claimed to be. Rmarkdown is terrific, so important that we cannot get along without it or its older competitors Sweave and knitr. In dependson=c("try1", "try2", "tr圓") the value c("try1", "try2", "tr圓") is a vector of character strings, the vector being made using R function c.įor a complete example using cache and dependson see the notes on Markov chain Monte Carlo and the Rmarkdown for that. In dependson="try1" the value "try1" is the name of a code chunk, so it is a character string. For example, in cache=TRUE the value TRUE is the R logical constant TRUE. If there are more than one of them, they must be collected into a vector using R function c. The value of the dependson chunk option, like all Rmarkdown chunk options, is an R object, thus it has to be valid R syntax. ![]() Then the code chunk is rerun whenever what is computed in those “depends on” code chunks change. You can use the dependson argument to tell a cached code chunk what other code chunks it depends on. So they should go in a different code chunk from any code chunks you want to cache. They need to be executed every time Rmarkdown runs. In particular, all calls to R function library should not be in cached code chunks. Never cache a code chunk that has important global side effects. If the code in the cached code chunk is changed, then it will be rerun.īut caching is dangerous because it does not know when it should rerun the code when something else has changed. ![]() Then they are only run once, the results are saved (in a directory, also called folder, on your computer) and every other time the code chunk is processed the cached results are used (so no computer time is taken redoing the long calculation). ![]() When code chunks take a long time to run, the option cache=TRUE can be added to them.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |