打印步骤成功能

时间:2017-11-08 12:47:58

标签: r

在这样的函数中:

words <- c("stock", "revenue", "continuous improvement")
phrases <- c("blah blah stock and revenue", "yada yada revenue yada", 
             "continuous improvement is an unrealistic goal", 
             "phrase with no match")

df<- data.frame(lapply(words, function(word) {as.numeric(grepl(word, phrases))}))

如何使用print(i),其中i是执行函数的短语数据帧的行数?旨在了解该过程需要多长时间结束。

1 个答案:

答案 0 :(得分:1)

试试这个,祝你好运

df<- data.frame(lapply(1:length(words), function(i) {print(i); as.numeric(grepl(words[i], phrases))}))