[R] getAttrb - Solved

Prof Brian D Ripley ripley at stats.ox.ac.uk
Thu Sep 7 08:05:36 CEST 2000

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

> Hi,
> I changed 
> INTEGER(getAttrib(shape,mkChar("nParts")))[0]
> to
> INTEGER(getAttrib(shape,mkString("nParts")))[0]
> and now it works fine.

In `Writing R Extensions' you would have seen that the second argument of
getAttrib (and setAttrib) is the name in the symbol table, and the way to
get that is install("nParts"). (Towards the end of section 3.6.4.)  The
first line of getAttrib is in fact

    if (isString(name)) name = install(CHAR(STRING_ELT(name, 0)));

which shows that mkString is immediately being undone.

These internals are not very extensively documented, but this call was.
In other cases, look at the usage in the code of R itself (src/main/*.c)
for clarification.

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