[R] filtering values

Thomas Lumley thomas at biostat.washington.edu
Wed Jul 5 17:49:04 CEST 2000


On Wed, 5 Jul 2000, amorgan wrote:

> I was wondering if there is a simple way to filter out a bunch of
> specific vales from a vector (eg zero).

x[x!=42] removes all the 42s 
x[!is.na(x)] removes all the NAs

 
> Also, is there a way to create a null vector?  What I mean by this is
> that if I declare a vector vector <- NA, it is a vector with [NA].  I
> want an empty vector, so that I can append to it later.

numeric(0) is a vector of length 0. Remember that repeatedly appending is
slower than creating a vector and then putting things in it.

	-thomas

Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list