@premsheth wrote:
Hi,
I am trying to do multiple replacement with single function.
I want to replace some words with 1 category word
For example:
“Scrubs & Body Treatments”,"Exfoliators, Polishes & Scrubs ",“Scrubs & Body Treatments” these three words and now I want replace there name with "Scrub"
I tried to create function as follows:
myfun <- function(pattern,replacement,x){
result <- list()
for (i in 1:length(pattern)) {
result[i] <- gsub(pattern[i],replacement,x)
}
result
}
but its not working.
Thanks in Advance
Posts: 2
Participants: 2