attributes on symbols

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

attributes on symbols

R devel mailing list
The multcomp package has code in multcomp:::expression2coef that attaches
the 'coef' attribute to symbols.  Since there is only one symbol object in
a session with a given name, this means that this attaching has a global
effect.  Should this be quietly allowed or should there be a warning or an
error?

E.g.,

str(quote(Education))
# symbol Education
lmod <- stats::lm(Fertility ~ ., data = datasets::swiss)
glmod <- multcomp::glht(lmod, c("Agriculture=0", "Education=0"))
str(quote(Education))
# symbol Education
# - attr(*, "coef")= num 1

Bill Dunlap
TIBCO Software
wdunlap tibco.com

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: attributes on symbols

Torsten Hothorn-5

Here is a simpler example:

> ex <- as.name("a")
> attr(ex, "test") <- 1
> quote(a)
a
attr(,"test")
[1] 1

Torsten

On Thu, 6 Jul 2017, William Dunlap wrote:

> The multcomp package has code in multcomp:::expression2coef that attaches the 'coef' attribute to
> symbols.  Since there is only one symbol object in a session with a given name, this means that
> this attaching has a global effect.  Should this be quietly allowed or should there be a warning or
> an error?
> E.g.,
>
> str(quote(Education))
> # symbol Education
> lmod <- stats::lm(Fertility ~ ., data = datasets::swiss)
> glmod <- multcomp::glht(lmod, c("Agriculture=0", "Education=0"))
> str(quote(Education))
> # symbol Education
> # - attr(*, "coef")= num 1
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
>
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: attributes on symbols

Radford Neal
In reply to this post by R devel mailing list
Attributes on symbols seem like a bad idea to me.  An additional
obscure part of the global state seems undesirable.  I can't see how
any use of them would be preferrable to storing an environment in some
global variable, in which the same information could be recorded.

Note that the attributes on symbols are not saved when the workspace
is saved with q("yes").

   Radford Neal

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Loading...