[R] remove particular elements in a vector

2007-09-07 Thread kevinchang

Hi, 

Is there any build-in function allowing us to remove a particular group of
elements in a vector? 

For example, if I want to remove all the NA in the output of answer
function . Please help. Thanks

 answer(100) 
  [1]  1  2 NA  4 NA NA  7  8 NA NA 11 NA 13 14 NA 16 17 NA 19 NA NA 22 23
NA NA
 [26] 26 NA 28 29 NA 31 32 NA 34 NA NA 37 38 NA NA 41 NA 43 44 NA 46 47 NA
49 NA
 [51] NA 52 53 NA NA 56 NA 58 59 NA 61 62 NA 64 NA NA 67 68 NA NA 71 NA 73
74 NA
 [76] 76 77 NA 79 NA NA 82 83 NA NA 86 NA 88 89 NA 91 92 NA 94 NA NA 97 98
NA NA

-- 
View this message in context: 
http://www.nabble.com/remove-particular-elements-in-a-vector-tf4404489.html#a12565480
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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] remove particular elements in a vector

2007-09-07 Thread jim holtman
x - answer(100)
x - x[!is.na(x)]  # remove NAs

On 9/7/07, kevinchang [EMAIL PROTECTED] wrote:

 Hi,

 Is there any build-in function allowing us to remove a particular group of
 elements in a vector?

 For example, if I want to remove all the NA in the output of answer
 function . Please help. Thanks

  answer(100)
  [1]  1  2 NA  4 NA NA  7  8 NA NA 11 NA 13 14 NA 16 17 NA 19 NA NA 22 23
 NA NA
  [26] 26 NA 28 29 NA 31 32 NA 34 NA NA 37 38 NA NA 41 NA 43 44 NA 46 47 NA
 49 NA
  [51] NA 52 53 NA NA 56 NA 58 59 NA 61 62 NA 64 NA NA 67 68 NA NA 71 NA 73
 74 NA
  [76] 76 77 NA 79 NA NA 82 83 NA NA 86 NA 88 89 NA 91 92 NA 94 NA NA 97 98
 NA NA

 --
 View this message in context: 
 http://www.nabble.com/remove-particular-elements-in-a-vector-tf4404489.html#a12565480
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@stat.math.ethz.ch 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.



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

__
R-help@stat.math.ethz.ch 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.