[R] vector and NA

2009-06-23 Thread Alfredo Alessandrini
Hi,

I've a vector like this:

--
 inc[,5]
  [1]NANANANANANANA
  [8]NANANANANANANA
 [15]NANANANANANANA
 [22]NANANANANANANA
 [29]NANANANANANANA
 [36]NANANANANANANA
 [43]NANANANANANANA
 [50]NANANANANANANA
 [57]NANANANANANANA
 [64]NANANANANANANA
 [71]NANANANANANANA
 [78]NANANANA 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?


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.


Re: [R] vector and NA

2009-06-23 Thread Chuck Cleland
On 6/23/2009 5:41 AM, Alfredo Alessandrini wrote:
 Hi,
 
 I've a vector like this:
 
 --
 inc[,5]
   [1]NANANANANANANA
   [8]NANANANANANANA
  [15]NANANANANANANA
  [22]NANANANANANANA
  [29]NANANANANANANA
  [36]NANANANANANANA
  [43]NANANANANANANA
  [50]NANANANANANANA
  [57]NANANANANANANA
  [64]NANANANANANANA
  [71]NANANANANANANA
  [78]NANANANA 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@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

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


Re: [R] vector and NA

2009-06-23 Thread Sandor Benczik



alfreale wrote:
 
 
 I've a vector like this:
 
 inc[,5]
 
 How can I extract a vector without the NA value?
 
 

inc[,5][!is.na(inc[,5])]

-- 
View this message in context: 
http://www.nabble.com/vector-and-NA-tp24162879p24163839.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] vector and NA

2009-06-23 Thread John Kane


 ?is.na and its negative !is.na
Try something like this
xx  - c(NA, NA, 1,  2,  3)
bb - xx[!is.na(xx)]
bb

--- On Tue, 6/23/09, Alfredo Alessandrini alfreal...@gmail.com wrote:

 From: Alfredo Alessandrini alfreal...@gmail.com
 Subject: [R] vector and NA
 To: r-help@r-project.org
 Received: Tuesday, June 23, 2009, 5:41 AM
 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?
 
 
 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.
 


  __
The new Internet Explorer® 8 - Faster, safer, easier.  Optimiz
etexplorer/

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


[R] vector and NA

2009-06-23 Thread Paolo Sonego

as.vector(na.omit(inc[,5])

?na.omit

Paolo



Hi,

I've a vector like this:

--


 inc[,5]
  

 [1]NANANANANANANA
 [8]NANANANANANANA
[15]NANANANANANANA
[22]NANANANANANANA
[29]NANANANANANANA
[36]NANANANANANANA
[43]NANANANANANANA
[50]NANANANANANANA
[57]NANANANANANANA
[64]NANANANANANANA
[71]NANANANANANANA
[78]NANANANA 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?


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.