as.vector(x,mode)出错:无法强制类型'环境'矢量类型'任何'在r工作室

时间:2018-02-26 20:12:12

标签: r sentiment-analysis

我对推文进行情感分析,并将所有分析的数据绑定到数据框 bayes_final

执行以下代码后,错误为:

Error in as.vector(x, mode) : 
  cannot coerce type 'environment' to vector of type 'any'

这是代码,

library(sentiment)

bayes_final<-
data.frame(text=character(),emotion=character(),polarity=character(),stringsAsFactors=FALSE)

for (incremented_city_value in 1:cities_length) {

  # # using sentiment package to classify emotions

  bayes_emotions <- classify_emotion(tweets[[incremented_city_value]], algorithm='bayes')


  # # # # using sentiment package to classify polarities

  bayes_polarities = classify_polarity(tweets[[incremented_city_value]], algorithm='bayes')

  bayes_df_polarity = data.frame(text=tweets[[incremented_city_value]], emotion=bayes_emotions[,'BEST_FIT'], polarity=bayes_polarities[,'BEST_FIT'], stringsAsFactors=FALSE)

  bayes_final <- rbind(bayes_final,bayes_df_polarity)

}

0 个答案:

没有答案