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

From: John Kane <jrkrideau_at_yahoo.ca>
Date: Tue, 18 Mar 2008 09:04:09 -0400 (EDT)


?which

 x <- x[which(x==remove.value)]

>
> 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
>
> --
> View this message in context:
>
http://www.nabble.com/Remove-a-number-from-a-vector-tp16119616p16119616.html
> Sent from the R help mailing list archive at
> Nabble.com.
>
> ______________________________________________
> 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.
>



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:06: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