我有一组文件名:
f <- c("a", "b", "c")
我已经找到了digest
功能来做这个,你能告诉我是否选择了正确的任务功能?
我们也可以使用for
循环
for(i in f) print(digest(i, serialize = FALSE))
#[1] "0cc175b9c0f1b6a831c399e269772661"
#[1] "92eb5ffee6ae2fec3ad71c777531578f"
#[1] "4a8a08f09d37b73795649038408b5f33"
或者使用Vectorize
Vectorize(function(x) digest(x, serialize = FALSE))(f)
# a b
"0cc175b9c0f1b6a831c399e269772661" "92eb5ffee6ae2fec3ad71c777531578f"
# c
#"4a8a08f09d37b73795649038408b5f33"
Maby sapply可以为你工作
library(digest)
f <- c("a", "b", "c")
sapply(f, digest, algo="md5", serialize=F)
结果是:
a b c
"0cc175b9c0f1b6a831c399e269772661" "92eb5ffee6ae2fec3ad71c777531578f" "4a8a08f09d37b73795649038408b5f33"