[Rd] glm Argument-Evaluation Does Not Match Documentation.

2018-08-03 Thread Jorgen Harmse via R-devel
Details in documentation: "All of ‘weights’, ‘subset’, ‘offset’, ‘etastart’ and 
‘mustart’ are evaluated in the same way as variables in ‘formula’, that is 
first in ‘data’ and then in the environment of ‘formula’."
In fact, `data` is usually not an environment, and I have not seen arguments 
evaluated in `environment(formula)` when `data` is provided. (Information in 
`environment(formula)` is used, so presumably they are evaluated in an 
environment whose parent is `environment(formula)`.)


R --vanilla

R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> environment(glm)

> maintainer('stats')
[1] "R Core Team "
> df <- data.frame(x=1:3, y=c(pi,7,sqrt(2)), z=c(1,2.3,3))
> a <- 4:6; b <- 7:9
> lm <- glm(z ~ x+y, data=df, weights = a*b -> v)
> v # Check whether weights was evaluated in .GlobalEnv, the environment of the 
> formula.
Error: object 'v' not found
> env.df <- as.environment(df); lm <- glm(z ~ x+y, data=env.df, weights = a*b 
> -> v)
Error in list(z, x, y) : could not find function "list"
> parent.env(env.df) <- .GlobalEnv; lm <- glm(z ~ x+y, data=env.df, weights = 
> a*b -> v)
> v
Error: object 'v' not found
> ls(env.df) # show that weights was evaluated in env.df
[1] "v" "x" "y" "z"


Suggested rewrite: "All of ‘weights’, ‘subset’, ‘offset’, ‘etastart’ and 
‘mustart’ are evaluated in the same way as variables in ‘formula’. Values 
needed are found first in `data` and then usually in the environment of 
‘formula’ & its ancestors. (If `data` is provided but is not an environment 
then expressions are evaluated in an environment with content taken from `data` 
whose parent is `environment(formula)`.) Side effects of evaluating the 
arguments will usually NOT occur in the caller's frame."
I think this is correct, but what really happens is inside other functions with 
unusual argument evaluation, so I'm not certain.


Regards,
Jorgen Harmse
 
Sam’s Club Technology
Phone 512.633.2226 
jorgen.har...@samsclub.com
 
 
This e-mail and any files transmitted with it are confidential and intended 
solely
for the individual or entity to whom they are addressed.  If you have received
this e-mail in error, destroy it immediately.  Wal-Mart Confidential.
 

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


[Rd] Add to Documentation of atan2.

2021-05-18 Thread Jorgen Harmse via R-devel
The current documentation says that atan2(y,x) is the angle between the x-axis 
and the vector from the origin to (x,y), but what does this mean when x & y are 
complex? The function seems to pick theta with Re(theta) between -pi and pi and 
with tan(theta) (approximately) equal to y/x, but that leaves 2 (sometimes 3) 
options, and there must be a set (branch region with 3 real dimensions?) on 
which the function is discontinuous. Please add details.

Even for real inputs, it might help to spell out the behaviour on the negative 
x-axis. It mostly matches the branch-cut rules for the other functions, but 
atan2(0,0)==0 is a unexpected.

I also suggest ‘See Also’ links from trigonometric functions to hyperbolic 
functions and from hyperbolic functions to exponential & logarithmic functions.

Regards,
Jorgen Harmse.



> R.version.string

[1] "R version 4.0.4 (2021-02-15)"






[[alternative HTML version deleted]]

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