[R] Asking Favor For "Remove element with Particular Value In Vector"

Jim Lemon jim at bitwrit.com.au
Mon Aug 29 12:04:47 CEST 2011


chuan_zl wrote:

 > Dear All.
 >
 > I am Chuan. I am beginner for R.I facing some problem in remove 
element from
 > vector.I have a vector with size 238 element as follow(a part)
 >
 > [1] 0 18 24 33 44..................................[238] 255
 >
 > Let the vector label as "x",I want remove element "0" and "255".I try use
 > such function:
 >
 > x[x>0 & x<255]

Hi Chuan,
If you want to remove the specific values 0 and 255 from your vector, try:

x<-x[-which(x %in% c(0,255))]

Jim



More information about the R-help mailing list