[R] programming question

Thomas Lumley tlumley at u.washington.edu
Thu Nov 8 22:35:51 CET 2001

On Thu, 8 Nov 2001, Clayton Springer wrote:

> Dear r-help,
> I am trying to build a new function (to process rpart objects) that will
> output matrix that has a row for each node and a column for
> each feature. With each entry in the table is a numerical property
> at that node for that feature (e.g. surrogate split agreement, improvement).
> My current trouble is that the only clue to the identity of the feature is
> stored as the *name* of the feature.  Whereas a table is indexed by *number*.
> I have a list of sorted names, but I am having trouble translating a name
> into a number. If this where perl the answer would be a hash.
> Or can I directly index a table with an alphanumeric string. (ie. a hash).

You can index a matrix, dataframe, or list by names

eg using part of the summary.lm output
cc<-summary(lm(Fertility ~ . , data = swiss))$coef


Thomas Lumley			Asst. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle

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