Re: [Rd] last user argument missing from Rscript --verbose

2014-09-21 Thread Harris A. Jaffee
Terrific, and I appreciate your thoughts and encouragement.

So, getting back on-list, I propose a backward-incompatible change, with
or without --verbose, that the --args be included in the 'av' array, and
passed to R, only if there are user arguments to follow it.  The condition
for a first argument, at the time --args is currently included, is

(i0+1) < argc

Scott's fix, already in the devel version, solves my original complaint and
should continue to do so, as long as av[ac] continues to be the terminating
NULL.  That is, av[ac-1] is the last argument in the R command.

On Sep 20, 2014, at 4:39 PM, Martin Maechler  wrote:

> 
> On Fri, Sep 19, 2014 at 5:26 PM, Harris A. Jaffee  wrote:
> I must have searched the archives badly!
> 
> I did not suggest that, exactly.  My hack was a little more complicated,
> trying to honor what seemed to be the general intent of the code.  So, I
> only conditionally echo the argument at i=ac-1 (see attached). 
> 
> ​Thank you, I understand but think it's unnecessarily complicated.
> Rather I think that the following issue should ideally be handled:
> 
> There is​ ​also a more basic issue to decide, whether the "--args" should be 
> sent to
> R when nothing follows it, but that debate should occur on-list, if at all.
> 
> ​and if that is fixed (not sending '--args' if at the end), the simple fix 
> for verbose printing will be enough.
> 
> ​Yes, please go back on saying this on R-devel ... You did take it offline 
> (and some say that it is not allowed to put something private suddenly back 
> online, so I did not ...  but do not care if you do it here).​
> 
> 
> Martin
> ​ 
> 
>  
> 
> On Sep 19, 2014, at 9:14 AM, Scott Kostyshak  wrote:
> 
> > On Fri, Sep 19, 2014 at 8:12 AM, Martin Maechler
> 
> >  wrote:
> >>> Harris A Jaffee 
> >>>on Thu, 18 Sep 2014 19:32:29 +0200 writes:
> >> 
> >> (using  HTML, please don't )
> >> 
> >>> The loop that echoes the arguments almost always stops too soon.  It
> >>> apparently does that to avoid
> >>> echoing the "--args" (that had been inserted) when there are no user
> >>> arguments.  However, when there
> >>> are user arguments, the next element of the 'av' array is the last
> >>> argument and usually not "--args",
> >>> although it can be.
> >>> ?Rscript is a little sketchy:
> >>> `--verbose' gives details of what `Rscript' is doing.  Also passed
> >>>  on to R.
> >>> What is passed to R is correct, but the diagnostic is not:
> >>> $ Rscript --verbose /dev/null 1 2
> >>>  running
> >>>  '/path_to_R --slave --no-restore --file=/dev/null --args 1'
> >>> Fixed (only tested on Mac):
> >>> $ Rscript --verbose /dev/null 1 2
> >>>  running
> >>>  '/Library/Frameworks/R.framework/Versions/3.1/Resources/bin/R --slave
> >>> --no-restore --file=/dev/null --args 1 2'
> >> 
> >> You are right about the problem, also reproducible on Linux.
> >> You mention a 'fix'.
> >> It looks to me that is just
> >> 
> >> -   for(i = 1; i < ac-1; i++) fprintf(stderr, " %s", av[i]);
> >> +   for(i = 1; i < ac; i++) fprintf(stderr, " %s", av[i]);
> >> 
> >> in unix/Rscript.c, right ?
> > 
> > Yes, I suggested the same patch here:
> > http://r.789695.n4.nabble.com/patch-Rscript-off-by-one-error-in-output-td4693780.html
> > 
> > Scott
> > 
> >> BTW: If one use  -e 'commandArgs()'  instead of   /dev/null one
> >> sees that Rscript's "lying" about the last argument is not
> >> helpful anyway :
> >> 
> >>  Rscript --verbose -e 'commandArgs()'
> >> 
> >>  running
> >>'/usr/local64.sfs/app/R/R-3.1.1-inst/bin/R --slave --no-restore -e 
> >> commandArgs()'
> >> 
> >>  [1] "/usr/local64.sfs/app/R/R-3.1.1-inst/bin/exec/R"
> >>  [2] "--slave"
> >>  [3] "--no-restore"
> >>  [4] "-e"
> >>  [5] "commandArgs()"
> >>  [6] "--args"
> >> 
> >> because the '--args' appears anyway and indeed *is* passed to 'R'...
> >> 
> >> A better fix would rather suppress that; but I will commit the
> >> above change.
> > 
> > 
> > --
> > Scott Kostyshak
> > Economics PhD Candidate
> > Princeton University
> > 
> > __
> > 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


[Rd] Bug in new behaviour for all.equal and environments?

2014-09-21 Thread Kevin Ushey
Hi R-devel,

The following code:

all.equal(baseenv(), baseenv())

gives the error when run in a clean R session with latest R-devel (r66650):

kevin:~$ R --vanilla --slave -e "all.equal(baseenv(), baseenv())"
Error in all.equal.envRefClass(target[[i]], current[[i]],
check.attributes = check.attributes,  :
  attempt to apply non-function
Calls: all.equal ... all.equal.list -> all.equal -> all.equal.envRefClass
Execution halted

Although I don't know if it's helpful -- it appears that packages that
include some S4 machinery will effect the outcome of this error, e.g.
if we load 'Biobase' first:

kevin:~$ R --vanilla --slave -e
"suppressPackageStartupMessages(library(Biobase));
all.equal(baseenv(), baseenv())"
Error in target$getClass() : object '.refClassDef' not found
Calls: all.equal ... all.equal.list -> all.equal ->
all.equal.envRefClass -> 
Execution halted

We were bumping into an error with this in Rcpp -- we used all.equal
(through RUnit) to confirm that baseenv(), and a function returning
the base environment, would return TRUE.

For completeness:

kevin:~$ R --vanilla --slave -e "sessionInfo()"
R Under development (unstable) (2014-09-20 r66650)
Platform: x86_64-apple-darwin13.3.0 (64-bit)

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

Thanks,
Kevin

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Bug in new behaviour for all.equal and environments?

2014-09-21 Thread Rui Barradas

Hello,

In R 3.1.1 on Windows 7 it's ok.

> all.equal(baseenv(), baseenv())
[1] TRUE
> sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=Portuguese_Portugal.1252 
LC_CTYPE=Portuguese_Portugal.1252
[3] LC_MONETARY=Portuguese_Portugal.1252 LC_NUMERIC=C 


[5] LC_TIME=Portuguese_Portugal.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

Rui Barradas

Em 21-09-2014 18:06, Kevin Ushey escreveu:

Hi R-devel,

The following code:

 all.equal(baseenv(), baseenv())

gives the error when run in a clean R session with latest R-devel (r66650):

 kevin:~$ R --vanilla --slave -e "all.equal(baseenv(), baseenv())"
 Error in all.equal.envRefClass(target[[i]], current[[i]],
check.attributes = check.attributes,  :
   attempt to apply non-function
 Calls: all.equal ... all.equal.list -> all.equal -> all.equal.envRefClass
 Execution halted

Although I don't know if it's helpful -- it appears that packages that
include some S4 machinery will effect the outcome of this error, e.g.
if we load 'Biobase' first:

 kevin:~$ R --vanilla --slave -e
"suppressPackageStartupMessages(library(Biobase));
all.equal(baseenv(), baseenv())"
 Error in target$getClass() : object '.refClassDef' not found
 Calls: all.equal ... all.equal.list -> all.equal ->
all.equal.envRefClass -> 
 Execution halted

We were bumping into an error with this in Rcpp -- we used all.equal
(through RUnit) to confirm that baseenv(), and a function returning
the base environment, would return TRUE.

For completeness:

 kevin:~$ R --vanilla --slave -e "sessionInfo()"
 R Under development (unstable) (2014-09-20 r66650)
 Platform: x86_64-apple-darwin13.3.0 (64-bit)

 locale:
 [1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base

Thanks,
Kevin

__
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


Re: [Rd] last user argument missing from Rscript --verbose

2014-09-21 Thread Dirk Eddelbuettel

On 20 September 2014 at 19:55, Harris A. Jaffee wrote:
| Terrific, and I appreciate your thoughts and encouragement.
| 
| So, getting back on-list, I propose a backward-incompatible change, with
| or without --verbose, that the --args be included in the 'av' array, and
| passed to R, only if there are user arguments to follow it.  The condition
| for a first argument, at the time --args is currently included, is
| 
|   (i0+1) < argc
| 
| Scott's fix, already in the devel version, solves my original complaint and
| should continue to do so, as long as av[ac] continues to be the terminating
| NULL.  That is, av[ac-1] is the last argument in the R command.

In case you were unaware of it, r from littler (which has been around even
longer than Rscript) has always propagated its arguments into argv:

edd@max:~$ r -e'print(argv)' foo bar biz x=42
[1] "foo"  "bar"  "biz"  "x=42"
edd@max:~$ 

See http://dirk.eddelbuettel.com/code/littler.html and my blog pages on
littler at http://dirk.eddelbuettel.com/blog/code/littler/ for more about 'r'
and littler; pre-built binaries exist at CRAN for Debian and Ubuntu; and it
builds easily on a lot of other OSs.

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Bug in new behaviour for all.equal and environments?

2014-09-21 Thread Duncan Murdoch
On 21/09/2014, 1:38 PM, Rui Barradas wrote:
> Hello,
> 
> In R 3.1.1 on Windows 7 it's ok.
> 
>  > all.equal(baseenv(), baseenv())
> [1] TRUE
>  > sessionInfo()
> R version 3.1.1 (2014-07-10)
> Platform: x86_64-w64-mingw32/x64 (64-bit)

I'm not sure if that's really "ok", since it returns TRUE for any pair
of environments, e.g.

all.equal(baseenv(), emptyenv())

The current R-devel behaviour is temporary and certain to change.

Duncan Murdoch

> 
> locale:
> [1] LC_COLLATE=Portuguese_Portugal.1252 
> LC_CTYPE=Portuguese_Portugal.1252
> [3] LC_MONETARY=Portuguese_Portugal.1252 LC_NUMERIC=C 
> 
> [5] LC_TIME=Portuguese_Portugal.1252
> 
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
> 
> Rui Barradas
> 
> Em 21-09-2014 18:06, Kevin Ushey escreveu:
>> Hi R-devel,
>>
>> The following code:
>>
>>  all.equal(baseenv(), baseenv())
>>
>> gives the error when run in a clean R session with latest R-devel (r66650):
>>
>>  kevin:~$ R --vanilla --slave -e "all.equal(baseenv(), baseenv())"
>>  Error in all.equal.envRefClass(target[[i]], current[[i]],
>> check.attributes = check.attributes,  :
>>attempt to apply non-function
>>  Calls: all.equal ... all.equal.list -> all.equal -> 
>> all.equal.envRefClass
>>  Execution halted
>>
>> Although I don't know if it's helpful -- it appears that packages that
>> include some S4 machinery will effect the outcome of this error, e.g.
>> if we load 'Biobase' first:
>>
>>  kevin:~$ R --vanilla --slave -e
>> "suppressPackageStartupMessages(library(Biobase));
>> all.equal(baseenv(), baseenv())"
>>  Error in target$getClass() : object '.refClassDef' not found
>>  Calls: all.equal ... all.equal.list -> all.equal ->
>> all.equal.envRefClass -> 
>>  Execution halted
>>
>> We were bumping into an error with this in Rcpp -- we used all.equal
>> (through RUnit) to confirm that baseenv(), and a function returning
>> the base environment, would return TRUE.
>>
>> For completeness:
>>
>>  kevin:~$ R --vanilla --slave -e "sessionInfo()"
>>  R Under development (unstable) (2014-09-20 r66650)
>>  Platform: x86_64-apple-darwin13.3.0 (64-bit)
>>
>>  locale:
>>  [1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8
>>
>>  attached base packages:
>>  [1] stats graphics  grDevices utils datasets  methods   base
>>
>> Thanks,
>> Kevin
>>
>> __
>> 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
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel