[R] find row name with specific value
Rui Barradas
ruipbarradas at sapo.pt
Tue Aug 27 19:44:11 CEST 2013
Hello,
Try the following.
dat <- read.table(text = "
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
", header = TRUE)
idx <- which(dat$samp.depth == 2)[1]
rownames(dat)[idx]
Hope this helps,
Rui Barradas
Em 27-08-2013 18:24, catalin roibu escreveu:
> 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