Я пытаюсь выполнить анализ настроений в диапазоне csv-файла с данными разных лет. В конечном итоге я хочу сравнить настроение диапазона дат.
Я пытаюсь создать функцию в R, чтобы применить год к каждому настроению файлов.
GetSentiment <- function(file){
fileName <- glue("C:/Documents/Project/", file, sep = "")
fileName <- trimws(fileName)
# read in the new file
fileText <- glue(read_file(fileName))
fileText <- gsub("\\$", "", fileText)
# tokenize
tokens <- data_frame(text = fileText) %>% unnest_tokens(word, text)
# get the sentiment from the first text:
sentiment <- tokens %>%
inner_join(get_sentiments("bing")) %>%
count(sentiment) %>% # count the
spread(sentiment, n, fill = 0) %>%
mutate(sentiment = positive - negative) %>%
mutate(file = file) %>%
mutate(year = as.numeric(str_match(file, "d{4}"))) %>% # add the year
return(sentiment)
Я ожидаю выводафайлов положительных и отрицательных настроений, а также его имя файла и год (из имени файла). Вместо этого я получаю
Ошибка в ответе (., Настроение): возврат нескольких аргументов не разрешен