一个有趣的问题!我认为最简单的选择是设计一个特殊的函数,比如“multi”gsub():mgsub <- function(pattern, replacement, x, ...) { if (length(pattern)!=length(replacement)) { stop("pattern and replacement do not have the same length.") } result <- x for (i in 1:length(pattern)) { result <- gsub(pattern[i], replacement[i], result, ...) } result}这给了我:> mydata <- c("á","é","ó")> mgsub(c("á","é","ó"), c("a","e","o"), mydata)[1] "a" "e" "o"