[R] getAttrb - Solved

Prof Brian D Ripley ripley at stats.ox.ac.uk
Thu Sep 7 09:56:15 CEST 2000


On Thu, 7 Sep 2000, Nicholas Lewin-Koh wrote:

> I think what I found confusing is the extsenion writers manual states
> 
> "What happens if we want to add an attribute that is not pre-dened? We
> need to add a symbol for it via a call to install. Suppose for
> illustration we
> wanted to add an attribute "version" with value 3.0. We could use 
> 
> { 
> SEXP version; 
> PROTECT(version = allocVector(REALSXP, 1)); 
> REAL(version) = 3.0;
> setAttrib(ans, install("version"), version); 
>  UNPROTECT(1);
> }                  
> 
> So I assumed install was to install the attribute name in the symbol table
> but not to retrieve it. Maybe a little clarification there would help such
> as "intall can also be used in getAttrib() to retrive an attribute
> installed in the sybol table"

Alternatively, just read the very next sentence in that section:

`Using install when it is not needed is harmless and provides a
simple way to retrieve the symbol from the symbol table if it is already
installed.'

I don't think you will find anywhere that it says to use mkChar!

-- 
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