Difficulties using the r module
Johan,
It appears R is not found. Is it on the path? Does it have the same name on the Mac?
Yes, R is in the bath and is found in /usr/bin/R which is a link to /Library/Frameworks/R.framework/Resources/bin/R. Thanks for your help with this. Take care, Matt -- Matthew Routley http://matt.routleynet.org
I can't really think why it wouldn't work then. Perhaps it is to do
with \write18 and the right of TeX to run external programs? Or maybe
R on the mac does not take the same command-line options? In that case
the output of the texexec run should be revealing. R takes more than a
second to start up so there are noticable breaks in the output after
which error messages from R appear. Btw, the reason it does not work
on contextgarden is likely that R is not installed there.
Sorry I could not be of more assistance, Johan
2006/6/30, Matthew Routley
Johan,
It appears R is not found. Is it on the path? Does it have the same name on the Mac?
Yes, R is in the bath and is found in /usr/bin/R which is a link to /Library/Frameworks/R.framework/Resources/bin/R.
Thanks for your help with this.
Take care, Matt
-- Matthew Routley http://matt.routleynet.org _______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
-- Johan Sandblom N8, MRC, Karolinska sjh t +46851776108 17176 Stockholm m +46735521477 Sweden "What is wanted is not the will to believe, but the will to find out, which is the exact opposite" - Bertrand Russell
Johan Sandblom wrote:
I can't really think why it wouldn't work then. Perhaps it is to do with \write18 and the right of TeX to run external programs? Or maybe R on the mac does not take the same command-line options? In that case the output of the texexec run should be revealing. R takes more than a second to start up so there are noticable breaks in the output after which error messages from R appear. Btw, the reason it does not work on contextgarden is likely that R is not installed there.
one problem could be that R has this piping; i wonder why a program that takes a 50 meg installation does not support something --output or i must have missed something Hans -- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Hi Hans,
* Hans Hagen
one problem could be that R has this piping; i wonder why a program that takes a 50 meg installation does not support something --output or i must have missed something
R does support redirecting output to a file. Use R CMD BATCH [options] <infile> <outfile> -- Olaf
Olaf Mersmann wrote:
Hi Hans,
* Hans Hagen
[060702 13:25]: one problem could be that R has this piping; i wonder why a program that takes a 50 meg installation does not support something --output or i must have missed something
R does support redirecting output to a file. Use
R CMD BATCH [options] <infile> <outfile>
currently we use: \def\runR {\executesystemcommand{texmfstart --ifchanged=\Rfile\space --direct R "-q --save --restore < \Rfile\space > \Rfile.out"}} so how should it look then? Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
\def\runR {\executesystemcommand{texmfstart --ifchanged=\Rfile\space
--direct R CMD BATCH "-q --save --restore \Rfile\space \Rfile.out"}}
or some such, I do not really understand the quoting. The invocation
should change, options should not and redirectors should go away. Not
sure if this is better or worse in any way.
Johan
2006/7/2, Hans Hagen
Olaf Mersmann wrote:
Hi Hans,
* Hans Hagen
[060702 13:25]: one problem could be that R has this piping; i wonder why a program that takes a 50 meg installation does not support something --output or i must have missed something
R does support redirecting output to a file. Use
R CMD BATCH [options] <infile> <outfile>
currently we use:
\def\runR {\executesystemcommand{texmfstart --ifchanged=\Rfile\space --direct R "-q --save --restore < \Rfile\space > \Rfile.out"}}
so how should it look then?
Hans
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
_______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
-- Johan Sandblom N8, MRC, Karolinska sjh t +46851776108 17176 Stockholm m +46735521477 Sweden "What is wanted is not the will to believe, but the will to find out, which is the exact opposite" - Bertrand Russell
Johan Sandblom wrote:
\def\runR {\executesystemcommand{texmfstart --ifchanged=\Rfile\space --direct R CMD BATCH "-q --save --restore \Rfile\space \Rfile.out"}}
or some such, I do not really understand the quoting. The invocation should change, options should not and redirectors should go away. Not sure if this is better or worse in any way.
the quoting tells texmfstart not split this, < > | are passes ok that way" did you test it? Hans
I can confirm that this works from the command line: R CMD BATCH -q --save --restore rsample-r-1.tmp rsample-r-1.tmp.out using the sample file from the r module. Running this command for each of the r segments will produce the desired output. What I haven't determined is how to modify the r module \runR command. Simply replacing the current \runR with \def\runR {\executesystemcommand{texmfstart --ifchanged=\Rfile\space --direct R CMD BATCH -q --save --restore \Rfile\space \Rfile.out}} was not successful. But I'm quite unfamilier with ConTeXt at this level. As far as I can determine, the appropriate .out files are not being created, which the log file correctly indicates. The .tmp files are successfully extracted from the source file. Thanks for the help with this. Matt
I think some quoting is required:
\def\runR
{\executesystemcommand{texmfstart
--ifchanged=\Rfile\space --direct R CMD BATCH
"-q --save --restore \Rfile\space \Rfile.out"}}
works here, but then I am on Linux. I think eventually Mac expertise
may be required.
Johan
2006/7/5, Matthew Routley
I can confirm that this works from the command line:
R CMD BATCH -q --save --restore rsample-r-1.tmp rsample-r-1.tmp.out
using the sample file from the r module. Running this command for each of the r segments will produce the desired output. What I haven't determined is how to modify the r module \runR command. Simply replacing the current \runR with
\def\runR {\executesystemcommand{texmfstart --ifchanged=\Rfile\space --direct R CMD BATCH -q --save --restore \Rfile\space \Rfile.out}}
was not successful. But I'm quite unfamilier with ConTeXt at this level.
As far as I can determine, the appropriate .out files are not being created, which the log file correctly indicates. The .tmp files are successfully extracted from the source file.
Thanks for the help with this.
Matt
_______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
-- Johan Sandblom N8, MRC, Karolinska sjh t +46851776108 17176 Stockholm m +46735521477 Sweden "What is wanted is not the will to believe, but the will to find out, which is the exact opposite" - Bertrand Russell
I now discovered a side effect of using the R CMD BATCH invocation
instead of the piping. With the CMD R outputs the setting of options
in the first line and the result of proc.time at the end. Perhaps not
a problem, but it does require three more typed lines per R block.
Johan
2006/7/5, Johan Sandblom
I think some quoting is required:
\def\runR {\executesystemcommand{texmfstart --ifchanged=\Rfile\space --direct R CMD BATCH "-q --save --restore \Rfile\space \Rfile.out"}}
works here, but then I am on Linux. I think eventually Mac expertise may be required.
Johan
2006/7/5, Matthew Routley
: I can confirm that this works from the command line:
R CMD BATCH -q --save --restore rsample-r-1.tmp rsample-r-1.tmp.out
using the sample file from the r module. Running this command for each of the r segments will produce the desired output. What I haven't determined is how to modify the r module \runR command. Simply replacing the current \runR with
\def\runR {\executesystemcommand{texmfstart --ifchanged=\Rfile\space --direct R CMD BATCH -q --save --restore \Rfile\space \Rfile.out}}
was not successful. But I'm quite unfamilier with ConTeXt at this level.
As far as I can determine, the appropriate .out files are not being created, which the log file correctly indicates. The .tmp files are successfully extracted from the source file.
Thanks for the help with this.
Matt
_______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
-- Johan Sandblom N8, MRC, Karolinska sjh t +46851776108 17176 Stockholm m +46735521477 Sweden "What is wanted is not the will to believe, but the will to find out, which is the exact opposite" - Bertrand Russell
-- Johan Sandblom N8, MRC, Karolinska sjh t +46851776108 17176 Stockholm m +46735521477 Sweden "What is wanted is not the will to believe, but the will to find out, which is the exact opposite" - Bertrand Russell
Johan Sandblom
I think some quoting is required:
\def\runR {\executesystemcommand{texmfstart --ifchanged=\Rfile\space --direct R CMD BATCH "-q --save --restore \Rfile\space \Rfile.out"}}
works here, but then I am on Linux. I think eventually Mac expertise may be required.
Unfortunately, the quoting doesn't help. Closer inspection of the log file reveals lines such as: system(texmfstart --ifchanged=test-r-1.tmp --direct R CMD BATCH "-q --save --restore test-r-1.tmp test-r-1.tmp.out")...disabled. with both the original \runR and new, batch mode. Matt
I get no such output, either to stdout or in the log, in fact nothing
even similar. Does the "...disabled" indicate that it is not run,
possibly because of something TeX/ConTeXt-related?
Johan
2006/7/5, Matthew Routley
Johan Sandblom
writes: I think some quoting is required:
\def\runR {\executesystemcommand{texmfstart --ifchanged=\Rfile\space --direct R CMD BATCH "-q --save --restore \Rfile\space \Rfile.out"}}
works here, but then I am on Linux. I think eventually Mac expertise may be required.
Unfortunately, the quoting doesn't help. Closer inspection of the log file reveals lines such as:
system(texmfstart --ifchanged=test-r-1.tmp --direct R CMD BATCH "-q --save --restore test-r-1.tmp test-r-1.tmp.out")...disabled.
with both the original \runR and new, batch mode.
Matt
_______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
-- Johan Sandblom N8, MRC, Karolinska sjh t +46851776108 17176 Stockholm m +46735521477 Sweden "What is wanted is not the will to believe, but the will to find out, which is the exact opposite" - Bertrand Russell
On Wed, 5 Jul 2006, Matthew Routley wrote:
Johan Sandblom
writes: I think some quoting is required:
\def\runR {\executesystemcommand{texmfstart --ifchanged=\Rfile\space --direct R CMD BATCH "-q --save --restore \Rfile\space \Rfile.out"}}
works here, but then I am on Linux. I think eventually Mac expertise may be required.
Unfortunately, the quoting doesn't help. Closer inspection of the log file reveals lines such as:
system(texmfstart --ifchanged=test-r-1.tmp --direct R CMD BATCH "-q --save --restore test-r-1.tmp test-r-1.tmp.out")...disabled.
with both the original \runR and new, batch mode.
This means that write18 is disabled on your system, so tex cannot execute any system commands. This is a security feature and most intallation disable write18 by default. You need to edit your texmf.cnf file to enable it. Search for texmf.cnf using texmfstart --locate texmf.cnf open that file in your favourite editor. Search for shell_escape and set it to true by shell_escape = t Save the file and write18 should work. Rerun texexec on your file and look at the log file. You should get system(....) executed. Aditya
Aditya Mahajan
This means that write18 is disabled on your system, so tex cannot execute any system commands. This is a security feature and most intallation disable write18 by default. You need to edit your texmf.cnf file to enable it. Search for texmf.cnf using
texmfstart --locate texmf.cnf
open that file in your favourite editor.
Search for shell_escape and set it to true by
shell_escape = t
This worked for enabling the commands. Of course, this revealed a new problem. texmfstart was not being called correctly. Replacing texmfstart with: ruby /usr/local/teTeX/share/texmf.local/scripts/context/ruby/texmfstart.rb , which is my path to texmfstart.rb, in \runR solved the problem. I had followed the "Other method" from the ConTeXt wiki for enabling texmfstart on my system. This works fine for calling commands from the command line, but (as suggested in the wiki) doesn't necessarily work for other methods. Once I sort out all of these OS X specific details, I'll post back to my original message with a solution. Thanks, Matt
2006/7/2, Hans Hagen
Johan Sandblom wrote:
I can't really think why it wouldn't work then. Perhaps it is to do with \write18 and the right of TeX to run external programs? Or maybe R on the mac does not take the same command-line options? In that case the output of the texexec run should be revealing. R takes more than a second to start up so there are noticable breaks in the output after which error messages from R appear. Btw, the reason it does not work on contextgarden is likely that R is not installed there.
one problem could be that R has this piping; i wonder why a program that takes a 50 meg installation does not support something --output or i must have missed something
I think R is most commonly used interactively in which case it is not needed. Anyway, OS X is a unix-alike so it should work fine. It even works on Windoze! The R MAC FAQ http://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html#Command-line-version-o... indicates that this approach should work. Johan
Hans
--
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
-- Johan Sandblom N8, MRC, Karolinska sjh t +46851776108 17176 Stockholm m +46735521477 Sweden "What is wanted is not the will to believe, but the will to find out, which is the exact opposite" - Bertrand Russell
The resolution to my problem was specific to Mac OS X and had nothing to do with the R module in particular. In case others have a similar problem, here is my solution. First, write18 must be enabled. As described by Aditya Mahajan, edit /usr/local/teTeX/texmf.cnf so that shell_escape = t. Second, create a texmfstart script as described in the "Configuration of texmfstart" section of http://wiki.contextgarden.net/Mac_Installation. I modified this slightly by placing the script in ~/bin so that I didn't interfere with the installed teTeX tree. Now the r module works. Thanks for everyone's help with this. Matt
participants (5)
-
Aditya Mahajan
-
Hans Hagen
-
Johan Sandblom
-
Matthew Routley
-
Olaf Mersmann