I want to replace the strings "aa" and "aaa" in the dataframe below with""
data = data.frame(attr = c(1:4), type1=c('aa','b'), type2=c("aaa", "aa"))
data <- apply(data,2,function(x) gsub("aa",'',x))
gsub takes every aa and gsub(c("aa", "aaa"),'',x) does not work