[R] Accessing just the value of an object but not the attributes

Prof Brian D Ripley ripley at stats.ox.ac.uk
Sat Oct 6 16:36:19 CEST 2001


On Tue, 2 Oct 2001, Johann Petrak wrote:

> I see the role of as.vector().
> But even if as.vector() needs to keep its attribute-dropping
> side-effect for compatibility reasons, wouldn't
> a dropattr() still be a good idea?

Not needed, as

attributes(x) <- NULL

removes all attributes.  I have no idea why this might be useful to you
.. remember that class and dim are attributes, for example.

Because they are not normally visible, assignment functions like
attributes<- are too little appreciated in S programming.

> For instance, I can assign attributes to closures, but
> wont get rid of them using as.vector() - and neither
> using as.function() by the way ...
> So if I dont know in advance what kind of object it is
> and I do want to just access the "value" in any case
> I have to check the type ... ?

[...]
-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list