On Mar 20, 2012, at 22:31 , Hadley Wickham wrote:
> Hi all,
>
> I can't figure out how to make this problem easily reproducible, but I
> can demonstrate it very simply, so I hoped someone might be able to
> suggest a place to start:
>
>> f <- function(x) substitute(x)
>> f(x)
> x
>> f(mpg)
> mpg
> attr(,"id")
> [1] 11
>
> It works as expected in a clean R session:
>
>> f <- function(x) substitute(x)
>> f(x)
> x
>> f(mpg)
> mpg
>
> but not after the following code
>
> library(devtools)
> install_github("staticdocs")
> library(staticdocs)
> build_package("ggplot2", tempdir())
>
> Any ideas?
>
Well, yes; you can get there more quickly as follows:
> x <- as.name("foo")
> attr(x,"id") <- 7913
> x
foo
attr(,"id")
[1] 7913> substitute(foo)
foo
attr(,"id")
[1] 7913
I.e. if you ever put an attribute on a symbol, it stays there
"forever". The fix is probably to forbid setting attributes on symbols
(as we already do for environments and NULL) but I bet that breaks something...
> Thanks,
>
> Hadley
>
> --
> Assistant Professor / Dobelman Family Junior Chair
> Department of Statistics / Rice University
> http://had.co.nz/
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com