我在加载和运行rjags时遇到问题。我可以安装rjags,但它不能运行,因为它找不到JAGS。下面列出了我的版本,并全部更新到最新版本。我也在用Thinkpad。JAGS版本: 4.3.0启用路径版本:2021.09.0build 351使用以下命令可以安装rjags : install.packages('rjags',configure.args=“-- RStudio -rpath”)
错误消息记录如下:
library(rjags)
Warning: package ‘rjags’ was built under R version 4.0.5
Error: package or namespace load failed for ‘rjags’:
.onLoad failed in loadNamespace() for 'rjags', details:
call: fun(libname, pkgname)
error: The environment variable JAGS_HOME is set to
C:/ProgramData/Microsoft/Windows/Start Menu/Programs/JAGS/JAGS-4.3.0
but no JAGS installation can be found there
如果转到安装JAGS的位置,路径为:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\JAGS
我使用了上面分享的几行代码来尝试解决这个问题,但是没有用:
Sys.setenv(JAGS_HOME="C:/ProgramData/Microsoft/Windows/Start Menu/Programs/JAGS/JAGS-4.3.0")
Error: unexpected '/' in "Sys.setenv(JAGS_HOME=C:/"
更正为:
Sys.setenv(JAGS_HOME="C:\ProgramData\Microsoft\Windows\Start Menu\Programs\JAGS\JAGS-4.3.0")
Error: '\P' is an unrecognized escape in character string starting ""C:\P"
更正为:
Sys.setenv(JAGS_HOME="C:\ ProgramData\ Microsoft\ Windows\ Start Menu\ Programs\ JAGS\ JAGS-4.3.0")
这不会产生任何错误,但当我尝试加载rjags时,我会得到以下结果:
library(rjags)
Warning: package ‘rjags’ was built under R version 4.0.5
Error: package or namespace load failed for ‘rjags’:
.onLoad failed in loadNamespace() for 'rjags', details:
call: fun(libname, pkgname)
error: The environment variable JAGS_HOME is set to
C: ProgramData Microsoft Windows Start Menu Programs JAGS JAGS-4.3.0
but no JAGS installation can be found there
这与上面的相同,但是由于某些原因,/被省略了。
不确定下一步要尝试什么,任何想法/见解都将非常感谢!:)
这似乎也是其他人面临的问题:rjags failed to load and R Failed to locate any version of JAGS https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/060fd5c378/?limit=25 https://www.reddit.com/r/rstats/comments/pzto5t/rjags_is_my_enemy/
尽管这些解决方案似乎都不起作用(还没有?)。
发布于 2021-10-13 15:17:35
问题解决了!
你们两个都是对的- JAGS在一个奇怪的位置,所以我把它移到了:
C:\Program Files\JAGS\JAGS-4.3.0
然后使用代码(我认为/与相同)
Sys.setenv(JAGS_HOME=“C:/程序文件/JAGS/JAGS-4.3.0”)
现在,它就像一个护身符一样工作:)
https://stackoverflow.com/questions/69558601
复制相似问题