
上QQ阅读APP看书,第一时间看更新
There's more...
The sub and gsub functions allow using regular expression to substitute a string. The sub and gsub functions perform the replacement of the first and all the other matches, respectively:
> sub("e", "q", names(iris)) Output: [1] "Sqpal.Length" "Sqpal.Width" "Pqtal.Length" "Pqtal.Width" "Spqcies" > gsub("e", "q", names(iris)) Output: [1] "Sqpal.Lqngth" "Sqpal.Width" "Pqtal.Lqngth" "Pqtal.Width" "Spqciqs"