[Rd] Error in glm(..., family=quasi(..., variance=list(...)))

2019-04-26 Thread Wollschlaeger, Daniel
In a glm() call using a quasi() family, one may define a custom variance 
function in the form of a "list containing components varfun, validmu, 
dev.resids, initialize and name" (quoting the help page for family). In trying 
to do so, I run into the following issue that I have not seen discussed 
previously:

x  <- runif(1000, min=0, max=1)
y  <- x + rnorm(1000, mean=0, sd=1)*x^(3/4)
vf <- function(mu) { abs(mu)^(3/4) }
vm <- function(mu) { rep(TRUE, length(mu)) }
dr <- function(y, mu, wt) { (y-mu)^2 }
it <- expression({ n <- rep.int(1, nobs); mustart <- y })
glm(y ~ x, family=quasi(link="identity", variance=list(varfun=vf, validmu=vm, 
dev.resids=dr, initialize=it, name="custom")))

This gives "Error in switch(vtemp, constant = { : EXPR must be a length 1 
vector" from line 576 in file family.R 
(https://github.com/wch/r-source/blob/5a156a0865362bb8381dcd69ac335f5174a4f60c/src/library/stats/R/family.R#L576).
 I believe this is due to line 573 "vtemp <- substitute(variance)" and 574 "if 
(!is.character(vtemp)) vtemp <- deparse(vtemp)" where vtemp becomes a length 2 
character vector because, by default, deparse() breaks lines at width.cutoff = 
60L characters. In stepping through quasi() during debug, setting vtemp <- 
(vtemp, collapse=" ") on line 576 avoids the error.

A workaround from https://tolstoy.newcastle.edu.au/R/help/05/06/6795.html 
appears to be to define one's own complete quasi2() function with the desired 
variance function pre-stored.

Is this known/expected, or should I file a bug?

Many thanks and best regards

Daniel

> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 14393)

Matrix products: default

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252   
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C   
[5] LC_TIME=German_Germany.1252

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

loaded via a namespace (and not attached):
[1] compiler_3.6.0

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


[Rd] Problem with a regular expression.

2017-08-17 Thread Wollschlaeger, Daniel
The issue seems related to R bug report 15012:

https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15012

As mentioned in the comments there, a pull request to the TRE library has 
recently been made, but I don't know about its status.

Daniel


Von: R-devel  im Auftrag von Tomas Kalibera 

Gesendet: Donnerstag, 17. August 2017 10:14
An: r-devel@r-project.org
Betreff: Re: [Rd] Problem with a regular expression.

The problem is in TRE library, in regcomp, while compiling the regular
expression.

This is enough to trigger in R (to do this without re-boot: ulimit -v
50 ):
 > strsplit("", ")")

To repeat in TRE, one can build TRE from sources and run
 > ./src/agrep ")" README.md

Tomas


On 08/17/2017 09:45 AM, Moshe Olshansky via R-devel wrote:
> I tried this on a Linux (Ubuntu) server invoking R from the command line and 
> the result was the same, except that I could kill the R session from another 
> terminal window.
>
>
>From: Rui Barradas 
>   To: Chris Triggs ; "r-devel@r-project.org" 
> 
> Cc: Thomas Lumley 
>   Sent: Thursday, 17 August 2017, 17:26
>   Subject: Re: [Rd] Problem with a regular expression.
>
> Hello,
>
> This seems to be serious.
> RGui.exe, fresh session. I've clicked File > New Script and wrote
>
> Oldterm <- c("A", "B", "A", "*", "B")
> strsplit(Oldterm, ")" )
>
> Ran each instruction at a time with Ctrl+r and with the strsplit call
> the system froze.
>
> Ctrl+Alt+Del didn't work, I had to go for the power switch button.
>
> sessionInfo()
> R version 3.4.1 (2017-06-30)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> Running under: Windows 7 x64 (build 7601) Service Pack 1
>
> Matrix products: default
>
> 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] statsgraphics  grDevices utilsdatasets  methods  base
>
> loaded via a namespace (and not attached):
> [1] compiler_3.4.1
>
>
> Rui Barradas
>
> Em 16-08-2017 23:31, Chris Triggs escreveu:
>> Hi...
>>
>> I have come upon a problem with a regular expression which causes base-R to 
>> freeze.  I have reproduced the phenomenon on several machines running R 
>> under Windows 10, and also under OSX  on different Apple MACs.
>>
>> The minimal example is:-
>> Oldterm is a vector of characters, e.g. "A", "B", "A", "*", "B"
>> The regular expression is ")"
>>
>> The call which freezes R is
>> strsplit(Oldterm, ")" )
>>
>> Thomas - after he had reproduced the problem - suggested that I submit it to 
>> r-devel.
>>
>> Best wishes
>>  Chris Triggs
>>
>>
>>  [[alternative HTML version deleted]]
>>
>> __
>> 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
>
>
>
>   [[alternative HTML version deleted]]
>
> __
> 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


Re: [Rd] undocumented 'offset' argument in src/library/grDevices/man/adjustcolor.Rd

2020-12-02 Thread Wollschlaeger, Daniel
One might say that adjustcolor() performs affine color transformation. Argument 
'offset' defines the shift in color space after the linear transformation 
defined by argument 'transform'. In other words, 'offset' represents additive 
color mixing (in the sense of adding lights, not paints) after linear 
transformation.

> red <- rgb(1, 0, 0)
> green <- c(0, 0.9, 0, 1)
> adjustcolor(red, 1, 0.9, 0.9, 0.9, offset=green)
[1] "#E6E600FF"

("red + green = yellow")

However, the implementation of adjustcolor() is a bit inconsistent with this 
description as it does not force 'offset' to be a color by using 
col2rgb(offset, alpha=TRUE)/255. The help page already gives an example for 
using 'offset' for the purpose of adding white light.

Von: R-devel  im Auftrag von Martin Maechler 

Gesendet: Mittwoch, 2. Dezember 2020 09:45:27
An: Ben Bolker
Cc: r-devel@r-project.org
Betreff: Re: [Rd] undocumented 'offset' argument in 
src/library/grDevices/man/adjustcolor.Rd

> Ben Bolker
> on Mon, 30 Nov 2020 16:33:23 -0500 writes:

> The 'offset' argument description is blank ...
> maybe 'additive adjustment to each of the (red, green, blue, alpha)
> values defining the colors, after adjustment by the corresponding
> \code{.f} factor' ...?

Thank you, Ben.   I'm using adjustcolor() very often, and I had
also wondered about the documentation "FIXME" there.

As I've not been a real expert in color space transformations, I
hadn't dared to describe it myself,  but your description above
is clearly better than the emptyness ...

Maybe someone can add something, or contribute some example(s)
on how using offset != 0  makes sense ?

> This is the relevant code:

>  x <- col2rgb(col, alpha = TRUE)/255
>  x[] <- pmax(0, pmin(1,
>  transform %*% x +
>  matrix(offset, nrow = 4L, ncol = ncol(x
>  rgb(x[1L,], x[2L,], x[3L,], x[4L,])

__
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