简体   繁体   English

无法在R中的包fanplot中找到运行示例的ew.txt文件

[英]Cannot find the ew.txt file running example from package fanplot in R

I am trying to follow an example in the package fanplot but I cannot find the ew.txt file. 我试图在包fanplot中跟随一个例子,但我找不到ew.txt文件。 I would be grateful for your help. 我很感激你的帮助。

data(ew)
plot(ew)

## Not run: 
plot(ew.mcmc)

##
##Create your own (longer) MCMC sample
##
# data
r <- diff(log(ew))
r <- ts(exp(r) - 1, start(ew))

library("R2OpenBUGS")
# write model file:
ew.bug <- dget(system.file("model", "ew.txt", package = "fanplot"))
write.model(ew.bug, "ew.txt")
# take a look:
file.show("ew.txt")
# run openbugs
ew.mcmc <- bugs(data = list(N = length(r), H = 25, r = c(r), p = c(ew)),
                inits = list(list(a = exp(12), psi = 0.5, itau2 = 0.5)),
                param = c("alpha", "psi", "tau", "r.new", "p.new", "y.sim"),
                model = "ew.txt", 
                n.iter = 11000, n.burnin = 1000, n.chains = 1, n.thin = 1)

## End(Not run)

The file is in R_LIBS/fanplot/model/ where R_LIBS is the location of your package library. 该文件位于R_LIBS/fanplot/model/ ,其中R_LIBS是包库的位置。

In the example code, the file is found via system.file() : 在示例代码中,通过system.file()找到该文件:

system.file("model", "ew.txt", package = "fanplot")

and then the next line writes the model to a the file ew.txt in the working directory. 然后下一行将模型写入工作目录中的文件ew.txt It is not clear which ew.txt you want. 目前尚不清楚你想要哪个ew.txt If the one that comes with the package find it in R_LIBS as above. 如果包中R_LIBS如上所述在R_LIBS找到它。 Or download the source tarball from CRAN (the tar.gz from the package page on cran . 或下载从CRAN源代码包( tar.gz上CRAN包页

When you run this code in an interactive session, use getwd to see what your working directory is. 在交互式会话中运行此代码时,请使用getwd查看工作目录是什么。 This should be the directory which contains the saved text file. 这应该是包含已保存文本文件的目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM