[Rd] Inappropriate class(o)[!inherits(o,"AsIs")] in get_all_vars

2019-11-17 Thread suharto_anggono--- via R-devel
SVN revision 77401 changes
x[isM] <- lapply(x[isM], function(o) `class<-`(o, class(o)[class(o) != 
"AsIs"]))
to
x[isM] <- lapply(x[isM], function(o) `class<-`(o, 
class(o)[!inherits(o,"AsIs")]))
in function 'get_all_vars' in src/library/stats/R/models.R in R devel.

The change is inappropriate.

class(o)[class(o) != "AsIs"] removes "AsIs" from class(o), giving class(o) 
without "AsIs".

On the other hand, inherits(o,"AsIs") is just a single logical value. If "AsIs" 
is in class(o), inherits(o,"AsIs") is TRUE. In that case, by recycling of 
logical index, class(o)[!inherits(o,"AsIs")] removes all elements of class(o), 
giving character(0).

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


[Rd] BUG?: A copy of base::`+` (primitive) is not a clone but a "pointer"

2019-11-17 Thread Henrik Bengtsson
$ R --vanilla
R version 3.6.1 (2019-07-05) -- "Action of the Toes"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
...

> str(base::`+`)
function (e1, e2)

> plus <- structure(base::`+`, class = "plus")
> str(plus)
function (e1, e2)
 - attr(*, "class")= chr "plus"

## Hmm ...
> str(base::`+`)
function (e1, e2)
 - attr(*, "class")= chr "plus"

> class(base::`+`) <- NULL
> str(base::`+`)
function (e1, e2)

## Hmm ...
> str(plus)
function (e1, e2)

Even without assigning to `plus`, you get this behavior:

$ R --vanilla
> structure(base::`+`, class = "plus")
function (e1, e2)  .Primitive("+")
attr(,"class")
[1] "plus"

# Hmm...
> str(base::`+`)
function (e1, e2)
 - attr(*, "class")= chr "plus"

Looks to be the case for common (all?) .Primitive functions.  Is this
expected? Should I report this one to BugZilla?

/Henrik

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


[Rd] Suggestion: Make _R_CHECK_LENGTH_1_LOGIC2_=warn the default for R 3.6.2

2019-11-17 Thread Henrik Bengtsson
Hi,

I'm not sure where we are in getting CRAN packages getting their
_R_CHECK_LENGTH_1_LOGIC2_=true bugs fixed (*), but maybe it'd help to
make _R_CHECK_LENGTH_1_LOGIC2_=warn the new default in the upcoming R
3.6.2? Warnings of type:

$ R --vanilla
> Sys.setenv("_R_CHECK_LENGTH_1_LOGIC2_" = "warn")
> c(TRUE, FALSE) && TRUE
[1] TRUE
Warning message:
In c(TRUE, FALSE) && TRUE : 'length(x) = 2 > 1' in coercion to 'logical(1)'

could help encourage more package maintainers to fix these bugs
sooner. Enabling this warning by default is in line with what the
current default behavior for _R_CHECK_LENGTH_1_CONDITION_ bugs:

> if (c(TRUE, FALSE)) 42
[1] 42
Warning message:
In if (c(TRUE, FALSE)) 42 :
  the condition has length > 1 and only the first element will be used

which has been the case for many years.

Hopefully in a not too far future, we get to a point where we can have
_R_CHECK_LENGTH_1_LOGIC2_=true and _R_CHECK_LENGTH_1_CONDITION_=true
as the new defaults.

(*) I understand that CRAN incoming checks with
_R_CHECK_LENGTH_1_LOGIC2_=package:_R_CHECK_PACKAGE_NAME_,abort,verbose,
so all packages submitted to CRAN have to pass this check.  I don't
think Bioconductor checks for these yet, but I could be wrong.

/Henrik

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