Re: [R] replace certain elements in data frame

From: sneaffer <>
Date: Sat, 23 Apr 2011 18:01:22 -0700 (PDT)


Try the following code:

d=c(1000,8210,9000,8310, 7000)


df = data.frame(a,b,c,d,e)
xdf <- apply(df, 2, function(x) x %in% to.replace) df[xdf] <- "others"

View this message in context:
Sent from the R help mailing list archive at

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Sun 24 Apr 2011 - 05:47:23 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 Sun 24 Apr 2011 - 06:10:32 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive