[R] first value...

Petr PIKAL petr.pikal at precheza.cz
Tue Jun 23 16:16:27 CEST 2009


Hi

r-help-bounces at r-project.org napsal dne 23.06.2009 16:04:49:

> Try this:
> 
>  which(diff(is.na(inc)) < 0)

Shall it be

which(diff(is.na(inc)) < 0)+1 

or

sum(is.na(inc))+1

or any other suitable construct with is.na

Regards
Petr


> 
> On Tue, Jun 23, 2009 at 11:00 AM, Alfredo Alessandrini 
<alfreale74 at 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 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.
> >
> 
> 
> 
> -- 
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
> 
>    [[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