[R] vector and NA

Chuck Cleland ccleland at optonline.net
Tue Jun 23 12:58:07 CEST 2009


On 6/23/2009 5:41 AM, Alfredo Alessandrini wrote:
> Hi,
> 
> I've a vector like this:
> 
> ------------------------------------------------------
>> inc[,5]
>   [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 19.842701
> [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
> -------------------------------------------
> 
> How can I extract a vector without the NA value?

na.omit(inc[,5])

?na.omit

> 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. 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894




More information about the R-help mailing list