On Tue, 2 Mar 2004 [EMAIL PROTECTED] wrote:

> Apparently row names are dropped when I extract
> single column from a data frame. Why this behaviour ?
> 
> > y <- as.matrix(df[,1:2]); length(row.names(y))
> [1] 324
> > y <- as.matrix(df[,1:1]); length(row.names(y))
> [1] 0

Why are you converting a subsetted data frame to a matrix?  df[, 1:2] is a 
data frame, and df[, 1:1] is a single column (most likely a vector). The 
latter is not going to have row names, but it might have names.  It 
happens that in S the row names are not copied across as names.

row.names applies to a data frame, and not to a matrix, strictly.

-- 
Brian D. Ripley,                  [EMAIL PROTECTED]
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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to