Re: [R] Re move a number from a vector

From: Albert Greinoecker <albert.greinoecker_at_uibk.ac.at>
Date: Tue, 18 Mar 2008 14:05:28 +0100

does
> x[!x == remove.value]

do what you need?

[1] 2 6 9 10

regards,
Albert

Am Dienstag, den 18.03.2008, 05:21 -0700 schrieb Josh Roofchop:
> This should be an easy one, but I haven't been able to figure it out,
>
> x<-c(2, 4, 6, 9, 10)
> #how do I remove a single value
> x<-x[-2] # will remove the second element of the vector not the number 2
>
> This is part of a loop that looks a little like this...
>
> x<-c(2, 4, 6, 9, 10)
> remove.value<-4
> #then I need to remove the value returned by the loop.
>
> Thanks,
> Josh
>



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. Received on Tue 18 Mar 2008 - 13:09:30 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 18 Mar 2008 - 13:30:22 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive