[R] Starting NONMEM (nmfe6) from R
Michal Figurski
figurski at mail.med.upenn.edu
Wed Aug 5 20:39:54 CEST 2009
Dear Scott (and all),
Thanks for sharing your idea - it helped me solve the problem. The issue
was actually the "nmfe6.bat" itself - there was plenty of references
such as "%dir%", "%nmdir%", etc. I replaced them all with full paths.
Additionally, I put all the PATH settings from "NMdirectories.bat" into
the "nmfe6.bat" to save on number of files that I have to call. I also
deleted most of the error-checking code and left only the lines calling
directly to the NONMEM components.
If anyone is interested, I replaced both the ":tran" and ":compile"
parts of the "nmfe6.bat" with the following code:
------------------------------------------------
:tran
K:\NONMEMCourse\nmvi\tr\nmtran.exe < %1 > FMSG
type FMSG
copy fsubs fsubs.for > nul
makeg77bat
call g77compile
echo Starting nonmem execution ...
nonmem.exe
echo Stop Time: >>%2
date /t >>%2
time /t >>%2
goto exit
------------------------------------------------
When run in R, it displays a warning: "...execution failed with error
code 1", nevertheless NONMEM actually produces the tables. I placed the
edited "nmfe6.bat" in my project folder and used the following R
commands to execute it:
------------------------------------------------
setwd("K:\\PROJECT1\\")
shell("nmfe6 control.txt output.txt", wait=T)
------------------------------------------------
Therefore, this works for me, for now. Nevertheless, if anyone has an
idea on what causes the warning message and how to make it run smoothly,
please share with me.
--
Michal J. Figurski, PhD
HUP, Pathology & Laboratory Medicine
Biomarker Research Laboratory
3400 Spruce St. 7 Maloney
Philadelphia, PA 19104
tel. (215) 662-3413
Scott Sherrill-Mix wrote:
> I believe R does system calls from its current working directory
> (getwd() will tell you where that is). This may not be the same
> directory you designed your .bat for. What if you use the full path
> for your files in the batch file? e.g.
> call K:\nmvi\nmfe6 "K:\nmvi\path\control.txt" "K:\nmvi\path\output.txt"
> Alternatively, you could make sure R is working in the right directory. e.g.
> setwd('K:\nmvi')
>
>
> Scott
>
> Scott Sherrill-Mix
> Department of Microbiology
> University of Pennsylvania
> 402B Johnson Pavilion
> 3610 Hamilton Walk
> Philadelphia, PA 19104-6076
> Phone: 215-573-3141
>
>
>
> On Wed, Aug 5, 2009 at 11:24 AM, Michal
> Figurski<figurski at mail.med.upenn.edu> wrote:
>> Hello,
>>
>> I have made an R script that prepares a NONMEM dataset and I would like to
>> start the NONMEM run right after the dataset is ready.
>>
>> I am using windows XP, R 2.9.1 and NONMEM 6.
>>
>> I have prepared a run.bat file that looks like this:
>> ----------------------------------------
>> call K:\nmvi\NMdirectories.bat
>>
>> call K:\nmvi\nmfe6 "path\control.txt" "path\output.txt"
>> ----------------------------------------
>>
>> The first call sets up all paths and directories, the second call starts
>> NONMEM. If I run this run.bat file directly in cmd window, it runs
>> correctly. However, if I use the R command:
>> shell("K:\\path\\run.bat", wait=T)
>> the first call runs correctly, but then the second produces and error "The
>> system cannot find the path specified." - completely as if the computer has
>> forgotten all the paths and settings from the first call.
>>
>> Does anyone know a solution to this problem?
>>
>> --
>> Michal J. Figurski, PhD
>> HUP, Pathology & Laboratory Medicine
>> Biomarker Research Laboratory
>> 3400 Spruce St. 7 Maloney
>> Philadelphia, PA 19104
>> tel. (215) 662-3413
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
More information about the R-help
mailing list