Re: [Rd] Rscript on Windows
I mentioned this twice already and no one answered;however, I am mentioning this a third time since its a serious deficiency. The Rscript facility that is upcoming in R is useful but on Windows one will often be relegated to having two files: a batch file and an R file unless the -x switch is implemented to allow them to be combined. This is not a problem on UNIX which supports #! but on Windows we need -x. Every other common scripting language including perl, python and ruby supports -x for this purpose. (The -x flag would start R processing at the first line that begins with #! so that prior lines could be Windows batch commands allowing the same file to be used as a batch file and an R file.) Note that there is a bug in Windows which means that if you simply associate .R to running R then the result cannot be redirected. There is a bug fix available for this but I think we need to be able to run out of the box for something this common. On 1/29/07, Gabor Grothendieck [EMAIL PROTECTED] wrote: Haven't got any feedback on this one. Will we be getting a perl/python/ruby style -x switch for Rscript for R 2.5.0? It certainly would give more flexibility to users of Rscript on non-UNIX systems where #! notation is not available. On 1/26/07, Gabor Grothendieck [EMAIL PROTECTED] wrote: Good idea. ruby seems to work the same way. python does too but with a slightly different definition: C:\ ruby -h | findstr strip -x[directory] strip off text before #!ruby line and perhaps cd to directory C:\ perl -h | findstr strip -x[directory] strip off text before #!perl line and perhaps cd to directory C:\ python -h | findstr skip -x : skip first line of source, allowing use of non-Unix forms of #!cmd On 1/26/07, Vladimir Eremeev [EMAIL PROTECTED] wrote: ActivePerl has '-x' switch which tells it to skip all lines in the file till #!. This allows writing perl scripts in ordinary .bat files. ?shQuote contains a link with the following perl script example: ===8=== @echo off :: hello.bat :: Windows executable Perl script :: Note: :: assumes perl.exe is in path :: otherwise, use absolute path perl -x -S %0 %* goto end #!perl print Hello, World!\n; __END__ :end :: -- end of hello.bat -- Windows Notes: -x (lower case x): Skip all text until shebang line. -S (upper case S): Look for script using PATH variable. Special meaning in Windows: appends .bat or .cmd if lookup for name fails and name does not have either suffix. %* only on WinNT/2K/XP; use %1 %2 . . . %9 on Win9x/DOS ===8=== I think the simplest way to implement shebang on windows would be embedding one more command line switch with similar functionality to perl's '-x'. -- View this message in context: http://www.nabble.com/Rscript-on-Windows-tf3120774.html#a8651815 Sent from the R devel mailing list archive at Nabble.com. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Requiring iconv
Sooner or later we are going to have to require iconv for fully functional R installations. The only systems we are aware of that do not come with a suitable iconv (with support for Unicode charsets like UTF-8) are some older commercial Unixen, and GNU libiconv works on those we know of. Does anyone have a system for which R's configure does not find a working iconv and on which they could not install GNU libiconv? I am contemplating that 2.5.0 would need to be explicitly configured with --without-iconv to allow it to be built on such a system, and that 'make check' would not then work. (An alternative would be to bundle libiconv with R, but it is 4Mb and would be needed very rarely. For Windows users we provide a DLL, which is compiled with VC++ as that is what works out of the box.) (capabilities(iconv) will tell you the status of a build if you have forgotten what happened at configure time.) -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] pinning down symbol values (Scoping/Promises) question
I would like to define a function using symbols, but freeze the symbols at their current values at the time of definition. Both symbols referring to the global scope and symbols referring to arguments are at issue. Consider this (R 2.4.0): k1 - 5 k [1] 100 a - function(z) function() z+k a1 - a(k1) k1 - 2 k - 3 a1() [1] 5 k - 10 k1 - 100 a1() [1] 12 First, I'm a little surprised that that the value for k1 seems to get pinned by the initial evaluation of a1. I expected the final value to be 110 because the z in z+k is a promise. Second, how do I pin the values to the ones that obtain when the different functions are invoked? In other words, how should a be defined so that a1() gets me 5+100 in the previous example? I have a partial solution (for k), but it's ugly. With k = 1 and k1 = 100, a - eval(substitute(function(z) function() z+x, list(x=k))) k - 20 a1 - a(k1) a1() [1] 101 (by the way, I thought a - eval(substitute(function(z) function() z+k)) would work, but it didn't). This seems to pin the passed in argument as well, though it's even uglier: a - eval(substitute(function(z) { z; function() z+x}, list(x=k))) a1 - a(k1) k1 - 5 a1() [1] 120 -- Ross Boylan wk: (415) 514-8146 185 Berry St #5700 [EMAIL PROTECTED] Dept of Epidemiology and Biostatistics fax: (415) 514-8150 University of California, San Francisco San Francisco, CA 94107-1739 hm: (415) 550-1062 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] R Language Manual: possible error
The R Language manual, section 4.3.4 (Scope), has f - function(x) { y - 10 g - function(x) x + y return(g) } h - f() h(3) ... When `h(3)' is evaluated we see that its body is that of `g'. Within that body `x' and `y' are unbound. Is that last sentence right? It looks to me as if x is a bound variable, and the definitions given in the elided material seem to say so too. I guess there is hidden, outer, x that is unbound. Maybe the example was meant to be g - function(a) a + y? The front page of the manual says The current version of this document is 2.4.0 (2006-11-25) DRAFT. -- Ross Boylan wk: (415) 514-8146 185 Berry St #5700 [EMAIL PROTECTED] Dept of Epidemiology and Biostatistics fax: (415) 514-8150 University of California, San Francisco San Francisco, CA 94107-1739 hm: (415) 550-1062 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] pinning down symbol values (Scoping/Promises) question
See ?force a - function(z) { force(k) function() z+k } On 2/16/07, Ross Boylan [EMAIL PROTECTED] wrote: I would like to define a function using symbols, but freeze the symbols at their current values at the time of definition. Both symbols referring to the global scope and symbols referring to arguments are at issue. Consider this (R 2.4.0): k1 - 5 k [1] 100 a - function(z) function() z+k a1 - a(k1) k1 - 2 k - 3 a1() [1] 5 k - 10 k1 - 100 a1() [1] 12 First, I'm a little surprised that that the value for k1 seems to get pinned by the initial evaluation of a1. I expected the final value to be 110 because the z in z+k is a promise. Second, how do I pin the values to the ones that obtain when the different functions are invoked? In other words, how should a be defined so that a1() gets me 5+100 in the previous example? I have a partial solution (for k), but it's ugly. With k = 1 and k1 = 100, a - eval(substitute(function(z) function() z+x, list(x=k))) k - 20 a1 - a(k1) a1() [1] 101 (by the way, I thought a - eval(substitute(function(z) function() z+k)) would work, but it didn't). This seems to pin the passed in argument as well, though it's even uglier: a - eval(substitute(function(z) { z; function() z+x}, list(x=k))) a1 - a(k1) k1 - 5 a1() [1] 120 -- Ross Boylan wk: (415) 514-8146 185 Berry St #5700 [EMAIL PROTECTED] Dept of Epidemiology and Biostatistics fax: (415) 514-8150 University of California, San Francisco San Francisco, CA 94107-1739 hm: (415) 550-1062 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel