lapply中出现意外的符号

时间:2019-02-14 09:20:01

标签: r

我尝试使用虚拟数据运行示例:

library(quanteda.dictionaries)
library(quanteda) 
 #dummy data
 df <- data.frame(text = c("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.", "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.", "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown inter took a galley of type and scrambled it t make a type specimen book."))

使用lapply而不是for循环来减少执行时间

df_list <- lapply(df$text, function(txt) {
     tryCatch({
         out <- liwcalike(txt, dictionary = data_dictionary_NRC)
         return(data.frame(em1=out$trust, em2=out$anger, origin=txt, error=NA))
     }, error = function(e) 
         data.frame(em1=NA, em2=NA, origin=txt, error=e)
     )
 }

final_df <- do.call(rbind, df_list)

但是我收到此错误

Error: unexpected symbol in:
"
final_df

我可以在此过程中解决什么问题?

0 个答案:

没有答案