简体   繁体   English

`文件错误(con,“r”):无法通过运行BRugsFit()打开连接

[英]`Error in file(con, “r”) : cannot open the connection` from running BRugsFit()

I have a error about Error in file(con, "r") : cannot open the connection from running BRugsFit().我有一个关于Error in file(con, "r") : cannot open the connection通过运行 BRugsFit() Error in file(con, "r") : cannot open the connection I assume all the input arguments are fine, and the calling code is我假设所有的输入参数都很好,调用代码是

> output = BRugsFit("model.txt", data, inits, numChains = 2, seed=6, parametersToSave,nBurnin = 100,nIter = 1000, nThin = 5, coda = T,digits = 5)

****
* BlackBox
* string too long
- HostFiles.Init  (pc=00003FB1, fp=BFFDE550)
- HostFiles.$$  (pc=0000000A, fp=BFFDE560)
****
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open file '/tmp/RtmpU7v9PZ/buffer.txt': No such file or directory

So I wonder what might be the reason of the error, and how to solve it?所以我想知道错误的原因可能是什么,以及如何解决它? Thank you so much!非常感谢!

It tells you that the file model.txt doesn't exist.它告诉您文件model.txt不存在。 Try to indicate the full path to the file:尝试指明文件的完整路径:

output <- BRugsFit("/path/to/file/model.txt", data, inits, numChains = 2, seed=6, parametersToSave,nBurnin = 100,nIter = 1000, nThin = 5, coda = T,digits = 5)

or first set the working directory with setwd :或者首先使用setwd设置工作目录:

setwd("/path/to/file/")

Sometimes, if I have spaces in a directory name (and/or dashes), R gives me the same errors (at least on OSX).有时,如果我在目录名称(和/或破折号)中有空格,R 会给我同样的错误(至少在 OSX 上)。

eg when the directory is '.../.../.../blah blah blah - blah' it does not work.例如,当目录是“.../.../.../blah blah blah - blah”时,它不起作用。

Renaming the folder to eg '.../.../.../blah_blah_blah-blah' resolves the issue.将文件夹重命名为例如 '.../.../.../blah_blah_blah-blah' 可以解决该问题。

I get this error when trying to write to a temporary directory, it looks like the above is the same problem.尝试写入临时目录时出现此错误,看起来上面的问题是相同的。 The directory is made, but the file cannot be written to that directory despite changing permissions.该目录已创建,但尽管更改了权限,但仍无法将文件写入该目录。 The working directory, the path to the file I am working with, and the path to the temporary directory are all fine.工作目录、我正在使用的文件的路径以及临时目录的路径都很好。 It looks like the OP is having the same conflict.看起来 OP 也有同样的冲突。

EDIT: I fixed this problem by changing the extension on the file.编辑:我通过更改文件的扩展名解决了这个问题。 Although both extensions referred to the same file type, the code would only take one of them.尽管两个扩展名都引用了相同的文件类型,但代码只会使用其中之一。 | | Sometimes closing the console/terminal and restarting it, loading the libraries again on start-up is all it needs.有时关闭控制台/终端并重新启动它,在启动时再次加载库就是它所需要的。 (presumably would work for the GUI without saving or using prior workspace) (大概可以在不保存或使用先前工作区的情况下为 GUI 工作)

In my case, it is because shiny create a new folder (outside .rproj file) that contain app.R file.就我而言,这是因为闪亮创建了一个包含 app.R 文件的新文件夹(在 .rproj 文件之外)。 Hence I need to move my css file to the same folder, or I specify the path folder which is less convenient因此我需要将我的 css 文件移动到同一个文件夹,或者我指定不太方便的路径文件夹

暂无
暂无

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

相关问题 R devtools :: release()file(con,“ r”)中的错误:无法打开连接 - R devtools::release() Error in file(con, “r”) : cannot open the connection R中的Osmar包“文件错误(con,“r”):无法打开连接” - Osmar package in R “Error in file(con, ”r“) : cannot open the connection” R:文件错误(con,“ r”):无法打开连接 - R: Error in file(con, “r”) : cannot open the connection 错误:文件错误(con,“ r”):无法打开连接 - Error: Error in file(con, “r”) : cannot open the connection arulesSequences cspade函数:“ file(con,“ r”)中的错误:无法打开连接” - arulesSequences cspade function: “Error in file(con, ”r“) : cannot open the connection” tm readPDF:文件错误(con,“r”):无法打开连接 - tm readPDF: Error in file(con, “r”) : cannot open the connection 文件错误(con,“rb”):无法打开连接 - Error in file(con, "rb") : cannot open the connection 文件错误(con,“wb”):无法打开连接 - Error in file(con, “wb”) : cannot open the connection 文件错误(con,“rb”):无法打开连接外置硬盘 R - Error in file(con, “rb”) : cannot open the connection External Hard Drive R Knitr 间歇性地无法在 URL 上执行 readLines,在文件中抛出错误(con,“r”):无法打开与<url></url> - Knitr intermittently fails to execute readLines on URLs, throws Error in file(con, "r") : cannot open the connection to <URL>
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM