1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| library(data.table) DT[ , lapply(.SD, function(x)iconv(x,"UTF8", "BIG5"))]
DT[ , lapply(.SD, function(x){ if (is.character(x)) iconv(x,"UTF8", "BIG5") } else return(x)})]
library(dplyr) DF %>% mutate_each(funs(iconv(., "UTF8", "BIG5")))
DF %>% mutate_if(is.character, funs(iconv(., "UTF8", "BIG5")))
evalExpr <- lapply(names(DF), function(x){ bquote(iconv(.(as.symbol(x)), "UTF8", "BIG5")) }) do.call(function(...) transform(DF, ...), evalExpr)
evalExpr <- lapply(names(DF)[sapply(DF, is.character)], function(x) bquote(iconv(.(as.symbol(x)), "UTF8", "BIG5"))) do.call(function(...) transform(DF, ...), evalExpr)
|