You can use this:

inc[which(!is.na(inc))[1]]


On Tue, Jun 23, 2009 at 11:08 AM, Alfredo Alessandrini <alfreale74@gmail.com
> wrote:

> I've the NA value also between the value of the vector:
>
> > inc
>  [1]        NA        NA        NA        NA        NA        NA        NA
>  [8]        NA        NA        NA        NA        NA        NA        NA
>  [15]        NA        NA        NA        NA        NA        NA        NA
>  [22]        NA        NA        NA        NA        NA        NA        NA
>  [29]        NA        NA        NA        NA        NA        NA        NA
>  [36]        NA        NA        NA        NA        NA        NA        NA
>  [43]        NA        NA        NA        NA        NA        NA        NA
>  [50]        NA        NA        NA        NA        NA        NA        NA
>  [57]        NA        NA        NA        NA        NA        NA        NA
>  [64]        NA        NA        NA        NA        NA        NA        NA
>  [71]        NA        NA        NA        NA        NA        NA        NA
>  [78]        NA        NA        NA        NA 13.095503 10.140119  7.989186
>  [85]  8.711888  7.201234 13.029250 14.430755  8.662832  8.810785 14.421302
>  [92]  7.614985  7.548091  9.843389 14.977402 20.875255  7.787543  2.005056
>  [99]  4.016916  3.601773  4.140390  7.241999 13.280794 18.038902 18.762169
> [106]  4.280065  5.942021  6.292010 11.866446 19.450442 11.942362  6.224328
> [113]  3.176050  5.456117  2.733487  3.992823 13.633171 19.514301 25.085256
> [120]  5.640089  5.890486 12.421150 18.821420 22.478664 11.503805  7.051254
> [127]  7.560921 12.000394 20.464875 16.147598 13.746290  9.416060 35.848221
> [134] 36.739481 23.516759  7.317599  3.928247 10.371437 11.202935 12.574649
> [141]  6.906980  9.191260  7.080267  2.810271  5.494705 10.617141 14.578020
> [148] 10.981610  7.343975  2.179511  2.726651 10.794842  9.872493        NA
> [155] 10.525064 16.134541 29.283385 18.352996  9.216318  6.253805  2.704267
> [162]  4.274514  3.138237 12.296835 20.982433 13.001104  2.606328  3.333271
> [169]  5.514425  2.179244  5.381514  6.848380  3.794428  5.114591  4.975830
> [176]  3.809948 10.131608 14.145913
> >
>
> > inc[82]
> [1] 13.09550
>
> >  which(diff(is.na(inc)) < 0)
> [1]  81 154
>
> > inc[154]
> [1] NA
>
>
> I must obtain only the first value, in this case: inc[82].
>
>
> Regards,
>
> Alfredo
>
>
>
>
> 2009/6/23 Henrique Dallazuanna <wwwhsd@gmail.com>
> >
> > Try this:
> >
> >  which(diff(is.na(inc)) < 0)
> >
> > On Tue, Jun 23, 2009 at 11:00 AM, Alfredo Alessandrini <
> alfreale74@gmail.com> wrote:
> >>
> >> Hi,
> >>
> >> I've a vector like this:
> >>
> >> > inc
> >>  [1]        NA        NA        NA        NA        NA        NA
>  NA
> >>  [8]        NA        NA        NA        NA        NA        NA
>  NA
> >>  [15]        NA        NA        NA        NA        NA        NA
>  NA
> >>  [22]        NA        NA        NA        NA        NA        NA
>  NA
> >>  [29]        NA        NA        NA        NA        NA        NA
>  NA
> >>  [36]        NA        NA        NA        NA        NA        NA
>  NA
> >>  [43]        NA        NA        NA        NA        NA        NA
>  NA
> >>  [50]        NA        NA        NA        NA        NA        NA
>  NA
> >>  [57]        NA        NA        NA        NA        NA        NA
>  NA
> >>  [64]        NA        NA        NA        NA        NA        NA
>  NA
> >>  [71]        NA        NA        NA        NA        NA        NA
>  NA
> >>  [78]        NA        NA        NA        NA 13.095503 10.140119
>  7.989186
> >>  [85]  8.711888  7.201234 13.029250 14.430755  8.662832  8.810785
> 14.421302
> >>  [92]  7.614985  7.548091  9.843389 14.977402 20.875255  7.787543
>  2.005056
> >>  [99]  4.016916  3.601773  4.140390  7.241999 13.280794 18.038902
> 18.762169
> >>
> >> I must obtain the position of first value of the vector...
> >>
> >> In this case is 82.
> >>
> >> > inc[82]
> >> [1] 13.09550
> >>
> >>
> >> Regards,
> >>
> >> Alfredo
> >>
> >> ______________________________________________
> >> R-help@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.
> >
> >
> >
> > --
> > Henrique Dallazuanna
> > Curitiba-Paraná-Brasil
> > 25° 25' 40" S 49° 16' 22" O
>
>
>
> --
> ----------------------------------------------
> Alfredo Alessandrini, Dr.
> Post-doc
> Department of Environment and Forest (DAF)
> Unitus - Viterbo
> http://www.unitus.it/dipartimenti/daf/dendro/
> ----------------------------------------------
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

	[[alternative HTML version deleted]]


