View source: R/SentimentAnalysis.R
1 | SentimentAnalysis(Dat)
|
Dat |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (Dat)
{
cat("\n")
profile_emot <- matrix(rep(0, length(Dat$filename) * 10),
ncol = 10)
for (i in 1:length(Dat$filename)) {
profile_emot[i, ] <- get_nrc_values(get_tokens(Dat$text[i]))/length(get_tokens(Dat$text[i]))
centex <- centerText_2(paste(Dat$profname, " Sentiment Analysis >>>>>>>>>> ",
round(i/length(Dat$filename) * 100, 2), "%", " >>>>>>>>>>>>>>>>>"))
cat("\r", centex$mid)
Sys.sleep(0.2)
}
cat("\n")
cat(" Writing Output ", "\n")
Emot_Mat <- cbind(filename = Dat$filename, profile_emot)
colnames(Emot_Mat) <- c("filename", names(get_nrc_values("joy")))
write.csv(Emot_Mat, paste0(Dat$profname, "_emot.csv"))
invisible(return(Emot_Mat))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.