Re: [R] how to get the row name?

From: Ionut Florescu <ifloresc_at_stevens.edu>
Date: Tue 31 Jan 2006 - 08:01:16 EST

I don't know about rownames but
x >= 0 gives you a vector of logical values True and false. If then you do
c(1:length(x)) [x>=0]
this gives the positions where the true happened, meaning your vector of values.

Chuck Cleland wrote:
> 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@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
>>
>
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> R-help@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



R-help@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 Received on Tue Jan 31 08:25:26 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:15 EST