根据这个吉特布问题 (标记为编织品1.12),应该可以在针织品中缓存Stan块,这样Stan模型对象就不需要每次我们编织文件时都重新编译。
但是,在使用RStudio v1.1.463中的针织v1.20 (Rv3.5.1)时,当第二次编织文件时(因此缓存已经构建),我会得到一个错误:
Quitting from lines 9-18 (Testing_Stan_cache.Rmd)
Error in fun(environment()) : invalid first argument
Calls: <Anonymous> ... call_block -> <Anonymous> -> lazyLoad -> lazyLoadDBexec -> fun
Execution halted示例Rmarkdown文件(错误中提到的第9-18行是Stan块):
---
title: "Testing Stan cache"
output: html_document
---
## Stan model
```{stan output.var="ex1", cache=TRUE}数据{
int X100;
}
参数{
real p;
}
模型{
X~ bernoulli(p);
}
## Run the model
```{r}图书馆(Rstan)
fit <-抽样(ex1,data=list(X = rbinom(100,1,0.3)
打印(适合)
我也在Stan块选项中尝试了cache.lazy=FALSE,但是得到了一个不同的错误:
Quitting from lines 23-26 (Testing_Stan_cache.Rmd)
Error in sampling(ex1, data = list(X = rbinom(100, 1, 0.3))) :
object 'ex1' not found
Calls: <Anonymous> ... withCallingHandlers -> withVisible -> eval -> eval -> sampling
Execution halted发布于 2018-12-07 03:34:44
这是的一个bug,我刚盯上了吉萨布。请尝试当前的开发版本:
remotes::install_github('yihui/knitr')https://stackoverflow.com/questions/53660143
复制相似问题