R 错误:找不到函数";将“情绪”分类;

R 错误:找不到函数";将“情绪”分类;,r,text-mining,R,Text Mining,我一直在尝试对一个随机文件进行情绪分析。但是,引发的错误是: could not find function "classify_emotion" “情绪”软件包不可用(适用于R版本3.1.2)。但是,通过以下方式获得了相同的安装:install\u github('mountain140','okugami79') 错误仍然存在:找不到函数“分类情绪” 守则: library(plyr) library(ggplot2) library(wordcloud) library(RColorBr

我一直在尝试对一个随机文件进行情绪分析。但是,引发的错误是:

could not find function "classify_emotion"
“情绪”软件包不可用(适用于R版本3.1.2)。但是,通过以下方式获得了相同的安装:
install\u github('mountain140','okugami79')

错误仍然存在:
找不到函数“分类情绪”

守则:

library(plyr)
library(ggplot2)
library(wordcloud)
library(RColorBrewer)
library(tm)
library(SnowballC)
library(sentiment)
library(Rcpp)
skill <- read.csv("C:/Users/632579/Desktop/skill.csv", header=FALSE, comment.char="#")
df<- data.frame(skill)
textdata <- df[df$data, ]
textdata = gsub("[[:punct:]]", "", textdata)
textdata = gsub("[[:punct:]]", "", textdata)
textdata = gsub("[[:digit:]]", "", textdata)
textdata = gsub("http\\w+", "", textdata)
textdata = gsub("[ \t]{2,}", "", textdata)
textdata = gsub("^\\s+|\\s+$", "", textdata)
try.error = function(x)
{
  y = NA
  try_error = tryCatch(tolower(x), error=function(e) e)
  if (!inherits(try_error, "error"))
    y = tolower(x)
  return(y)
}
textdata = sapply(textdata, try.error)
textdata = textdata[!is.na(textdata)]
names(textdata) = NULL
class_emo = classify_emotion(textdata, algorithm="bayes", prior=1.0)
emotion = class_emo[,7]
emotion[is.na(emotion)] = "unknown"
class_pol = classify_polarity(textdata, algorithm="bayes")
polarity = class_pol[,4]


sent_df = data.frame(text=textdata, emotion=emotion,polarity=polarity, stringsAsFactors=FALSE)
sent_df = within(sent_df,emotion <- factor(emotion, levels=names(sort(table(emotion), decreasing=TRUE))))
ggplot(sent_df, aes(x=emotion)) +
geom_bar(aes(y=..count.., fill=emotion)) +
scale_fill_brewer(palette="Dark2") +
labs(x="emotion categories", y="")

ggplot(sent_df, aes(x=polarity)) +
geom_bar(aes(y=..count.., fill=polarity)) +
scale_fill_brewer(palette="RdGy") +
labs(x="polarity categories", y="")
emos = levels(factor(sent_df$emotion))
nemo = length(emos)
emo.docs = rep("", nemo)
for (i in 1:nemo)
{
  tmp = textdata[emotion == emos[i]]
  emo.docs[i] = paste(tmp, collapse=" ")
}
emo.docs = removeWords(emo.docs, stopwords("english"))
corpus = Corpus(VectorSource(emo.docs))
tdm = TermDocumentMatrix(corpus)
tdm = as.matrix(tdm)
colnames(tdm) = emos
comparison.cloud(tdm, colors = brewer.pal(nemo, "Dark2"),
                 scale = c(3,.5), random.order = FALSE,
                 title.size = 1.5)
库(plyr)
图书馆(GG2)
图书馆(wordcloud)
图书馆(RColorBrewer)
图书馆(tm)
图书馆(SnowballC)
图书馆(情绪)
图书馆(Rcpp)

技巧> P>你应该考虑更新当前版本的R,更新你的包,看看这是否解决不了问题。考虑使用“安装程序”包更新.< /P>
如果您希望直接加载该函数,则可以找到该函数。

我遇到了相同/类似的问题。我必须先单独安装RStem am tm软件包。然后从磁盘上安装。然后它工作得很好。

我在github上也找不到该函数。你能告诉我它是在哪里推出的吗?我想它和你在github上找到的包不一样。您可以为cran archive安装
情绪
软件包,或者找到合适的github Repostroy来安装
RTextTools
软件包。但是现在给出:分类情绪错误(textdata,algorithm=“bayes”,prior=1):找不到函数“创建矩阵”您是否尝试直接加载函数或更新R?create_matrix是包中的另一个函数,也需要直接加载。我鼓励您更新R,然后尝试使用install.packages(“情绪”)安装包。3.1.2已经过时,许多软件包还不兼容。