[R] find row name with specific value

MacQueen, Don macqueen1 at llnl.gov
Wed Aug 28 17:04:29 CEST 2013


I would tend to go for very basic approach.
Since there is no column of data named 'year' I will assume that the row
names contain the year.

min( row.names(mydata)[mydata$samp.depth==2] )

Although it's not pretty, I think it comes close to representing in R the
language the request as presented in the English language.

This does assume all of the row names convert correctly to a numeric year
if one were to do
  as.numeric(row.names(mydata))


-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 8/27/13 10:24 AM, "catalin roibu" <catalinroibu at gmail.com> wrote:

>Hello all!
>I want to find the first year where is fixed value (eg 2).
>My data is like this:
> HUMstd    HUMres samp.depth
>1592 0.5687519        NA          1
>1593 1.5251896        NA          1
>1594 1.8168727        NA          1
>1595 1.1265923 0.8253599          1
>1596 0.8725422 0.7423323          2
>1597 0.6744835 0.5443933          2
>1598 0.7605894 0.8698533          2
>1599 0.6559708 0.8695049          2
>1600 0.8606666 0.4699240          3
>1601 1.0398217 1.0643867          3
>1602 0.5707846 0.7079530          3
>1603 0.5136122 0.8443149          3
>1604 0.6700944 0.9767793          3
>1605 0.7239053 0.9378163          3
>1606 0.6772079 0.8428935          3
>1607 0.9368149 1.0333812          3
>1608 0.7091008 0.7860034          3
>1609 1.1177742 1.2792296          3
>
>Thank you!
>
>-
>---
>Catalin-Constantin ROIBU
>Lecturer PhD, Forestry engineer
>Forestry Faculty of Suceava
>Str. Universitatii no. 13, Suceava, 720229, Romania
>office phone     +4 0230 52 29 78, ext. 531
>mobile phone   +4 0745 53 18 01
>                       +4 0766 71 76 58
>FAX:                +4 0230 52 16 64
>silvic.usv.ro
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list