[R] how to get the row name?

Chuck Cleland ccleland at optonline.net
Mon Jan 30 21:36:55 CET 2006


rownames(subset(mydata, X >=0))

?rownames

Leaf Sun wrote:
> Hi R-listers,
> 
> I have a simple question about a data frame.  
> 
> I sorted a data set by one of the variable in some condition (eg. X>=0),  the followed is part of the achieved. I was wondering how can I get the row name, i. e.   (1202,  2077 , 2328,  3341,...  ) and save them as a vector.     Thanks!
> 
> 			  Tag  Species     X     Y Dbh3 Recr4 mort slope elevation aspect    SA   SR     dist1     dist2     dist3
> 1202    19103     316 856.0 430.3   21     4    1  9.87    151.42  60.08 25.38 1.02 0.2236068 0.7211103 1.3601471
> 2077    29893     316 935.4 482.7   28     4    1  5.66    137.28  13.86 25.14 1.01 0.6403124 0.8944272 1.0630146
> 2328    32989     316 910.7 301.5   12     4    1  8.07    137.69  86.16 25.26 1.01 0.3000000 1.2806248 1.3038405
> 3341    45198     316 975.2   2.4  144     4    1  2.95    121.10 173.60  0.00 0.00 0.5656854 1.2727922 1.3416408
> ...
> 
> Regards,
> 
> Leaf
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894




More information about the R-help mailing list