[R] Weird R's behaviour with a quoted name

luke-tierney at uiowa.edu luke-tierney at uiowa.edu
Mon Nov 21 20:40:41 CET 2011


On Mon, 21 Nov 2011, William Dunlap wrote:

> This is a bug in R: it either should prohibit the
> attaching of attributes to things of class "name"
> or should make it so that attachment of an attribute
> doesn't have such a global effect.
>
> A more direct example of the problem is:
>  > attributes(quote(some.name))
>  NULL
>  > bar <- structure(quote(some.name), someAttribute="someAttribute's value")
>  > attributes(quote(some.name))
>  $someAttribute
>  [1] "someAttribute's value"
>
> I reported a similar problem to R-devel in March of
> 2010 under the subject line "symbol name caching bug:
> attributes get tied to symbol names".  The consensus
> then seemed to be that prohibiting attributes on things
> of class "name" was the way to go.

Yes -- just hasn't risen high enough on anyone's todo list to get done.

Best,

luke

>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
>
>> -----Original Message-----
>> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Kamil Barton
>> Sent: Monday, November 21, 2011 8:31 AM
>> To: r-help at r-project.org
>> Subject: [R] Weird R's behaviour with a quoted name
>>
>> Can someone explain why the following happens?
>> ---
>> :> quote(some.name)
>> some.name
>> :> bar <- structure(quote(some.name), class = "foo")
>> :> quote(some.name)
>> Error in print(some.name) : object 'some.name' not found
>> :> bar <- quote(some.name)
>> :> quote(some.name)
>> Error in print(some.name) : object 'some.name' not found
>> :> bar <- as.name("some.name")
>> :> quote(some.name)
>> some.name
>> ---
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:   luke-tierney at uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu



More information about the R-help mailing list