【发布时间】:2019-01-24 23:10:16
【问题描述】:
我在 neovim 中使用 R 和 nvim-r 使用 \kh 或 \kp 命令来编织 Rmd 文档。问题是当我编织一个适合 Rstan 模型的 Rmd 时,它会在此位置的一个单独的临时文件中打印 Rstan sampling() 调用的输出,包括链的进度:
file:///tmp/RtmpMmXreV/file27067eb3452f_StanProgress.html
包含此输出:
点击刷新按钮查看链的进度 在 14:31:54.447 在 localhost:11515 上启动 worker pid=17045 在 14:31:54.670 在 localhost:11515 上启动 worker pid=17070
它会在我的浏览器中打开该 html 文件。结果是每次新模型开始采样时,我的浏览器都会不断打开。这只发生在我使用options(mc.cores = parallel::detectCores()) 并行化链时。没有该命令,html 文件不会弹出。
是否可以阻止 nvim-r 打开这些临时 html 文件,或者是否可以使来自 Rstan 的链输出静音?
小例子:
library(rstan)
options(mc.cores = parallel::detectCores())
data(DNase)
model <- stan_model(model_code = "
data {
int n;
vector[n] conc;
vector[n] density;
}
parameters {
real b0;
real b1;
real<lower=0> sigma;
}
model {
conc ~ normal(b0 + b1 * (density), sigma);
b0 ~ normal(0, 10);
b1 ~ normal(0, 10);
sigma ~ normal(0, 10);
}")
fit <- sampling(model, data = list(n = nrow(DNase),
conc = DNase$conc,
density = DNase$density))
编辑:
我尝试将results="hide" 添加到块头,并将refresh = 0 添加到基于this answer 的sampling() 调用,但无济于事。 refresh = 0 确实成功删除了消息的 starting worker... 部分,但它仍会打开一个显示 Click the Refresh button to see progress of the chains 的 html 文件。
【问题讨论】: