[R] Connecting to winbugs from R

dolberdinho johannesdolberg at gmail.com
Tue Oct 27 09:31:52 CET 2009




Ben Bolker wrote:
> 
> 
> 
> dolberdinho wrote:
>> 
>> Hi,
>> 
>> I'm having trouble running a script within winbugs when calling winbugs
>> from R.
>> Here are a few lines from the winbugs log:
>> 
>> display(log)
>> check(C:\DOCUME~1\michael\LOCALS~1\Temp\RtmpjKnHMu\mm_TO_bugs9bc21e.txt)
>> cannot open
>> C:\DOCUME~1\michael\LOCALS~1\Temp\RtmpjKnHMu\mm_TO_bugs9bc21e.txt
>> data(C:/DOCUME~1/michael/LOCALS~1/Temp/RtmpjKnHMu/data.txt)
>> command #Bugs:data cannot be executed (is greyed out)
>> ...
>> 
>> Winbugs tries to check the mm_TO_bugs9bc21e.txt file but somehow it can't
>> and so it can't execute the rest of the commands. The file does exist. If
>> the path is pasted into windows explorer it opens nicely.
>> 
>> Here's the R script as well:
>> library(mixstock)
>> library(R2WinBUGS)
>> mydata <- read.table("C:/turtles/temp.txt")
>> mydata<-as.mixstock.data(mydata,4)
>> mydataC<-markfreq.condense(mydata)
>> m2m<-mm.wbugs(mydataC, n.iter=1000,n.chains=4,debug=TRUE)
>> 
>> Does anyone have a guess as to why the "mm_TO_bugs9bc21e.txt" won't open?
>> 
>> 
> 
> Dear Johannes,
> 
>   I think there is a *chance* that this problem comes from a total path
> length being too long ... this is an issue I may have seen before (but
> can't
> remember at the moment exactly what the issue was).
> Is there any chance you can send me your data & script files
> (bolker AT ufl.edu )?
> 
>   Ben Bolker
> 
> 

I just wanted to follow up on this in case someone else out there runs into
the same issue.

It turned out that the reason to mm_TO_bugs9bc21e.txt no opening was due to
the path being written with "\" characters instead of "/" characters. What
made the path appear in such a way is still unclear... however, a solution
was found. 

inserting a working.directory=getwd() into the winbugs statement made the
error go away:
m2m<-mm.wbugs(mydataC, n.iter=1000,n.chains=4,debug=TRUE,
working.directory=getwd())

Thanks to Ben and Uwe for sorting this out!

Best,
Johannes



-- 
View this message in context: http://www.nabble.com/Connecting-to-winbugs-from-R-tp26034409p26073896.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list