replace string in dataframe
问题 I'm trying to replace a certain string in a large data.frame. I just found the following solution but gsub doesn't preserve the original data.frame layout. How can I achieve this. I mean I want to replace a string and don't want to change the layout of the df. Consider this example: test<-data.frame(a=c("a","b","c","d"),b=c("a","e","g","h"),c=c("i","j","k","a")) gsub("a","new",test) Thx 回答1: You will want to lapply through your data.frame testing for character or factor entries and then