library(shiny)
library(shinythemes)
## Warning: package 'shinythemes' was built under R version 4.1.3
library(syuzhet)
library(RColorBrewer)
## Warning: package 'RColorBrewer' was built under R version 4.1.3
ui <- fluidPage(theme = shinytheme("slate"),
navbarPage("Aplicaciones",
tabPanel("Análisis de Sentimientos",
sidebarPanel(tags$h4("Pega el texto aquí:"),
textAreaInput("texto", "", "", rows=15),
selectInput("emoción", "Selecciona la barra más alta del análisis de emociones:", c("joy", "sadness", "anger", "surprise", "disgust", "fear", "anticipation", "trust"))
),
mainPanel(h2("El análisis de Emociones es:"),
plotOutput("Gráfica_Emociones"),
h2("El análisis de Sentimientos es:"),
plotOutput("Gráfica_Sentimientos"))
)))
server <- function(input, output) {
output$Gráfica_Emociones <- renderPlot({
texto_cadena <- input$texto
texto_palabras <- get_tokens(texto_cadena)
emociones_df <- get_nrc_sentiment(texto_palabras, language = "spanish")
barplot(
colSums(prop.table(emociones_df[, 1:8])),
space = 0.2,
horiz = FALSE,
las = 1,
cex.names = 0.7,
col = brewer.pal(n=8, name = "Set3"),
main = "Análisis de Emociones",
xlab = "emociones"
)
})
output$Gráfica_Sentimientos <- renderPlot({
texto_cadena <- input$texto
texto_palabras <- get_tokens(texto_cadena)
emociones_df <- get_nrc_sentiment(texto_palabras, language = "spanish")
secuencia_sentimientos <- (emociones_df$negative*-1)+emociones_df$positive
simple_plot(secuencia_sentimientos)
})
}
shinyApp(ui = ui, server = server)
Shiny applications not supported in static R Markdown documents