[R] dimnames
Prof Brian D Ripley
ripley at stats.ox.ac.uk
Sun Nov 14 21:48:53 CET 1999
On Sun, 14 Nov 1999 cstrato at EUnet.at wrote:
> Maybe this is a simple question:
>
> Using S-Plus, and having a matrix m with row- and col-names, I have the
> following problem:
>
> When I import into a function the one-column matrix m[,i], I am no
> longer able to get the
> column name. Is there a way to get the column-name?
>
> (Although attributes(m) displays row- and col-names, attributes(m[,i])
> does no longer show
> the col-name.)
If i is a single number, m[, i] is not a matrix but a vector. You need
m[,i, drop=F] to preserve it as a one-column matrix.
You can use dimnames() to see the column names, or colnames() in R.
I am not sure why you sent an S-PLUS question to R-help: would not S-news
be more appropriate? (Because of the presence of colnames() in R, the
answer might be subtly different.)
--
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