ShinnyApp: Throwing Errors


I am new to Shinny, I have an issue running my ShinnyApp
I get these two errors below:
"no applicable method for 'mutate_' applied to an object of class "function" (for hist_plot), and," cannot coerce type 'closure' to vector of type 'any' (for plot_emotions), where are these errors coming from??

plot_emotion <- function(clean.tweets.dataframe){
  senti <- get_nrc_sentiment(as.character(tweet.corpus))
  senti.df <- data.frame("number" = colSums(senti[,]))
  senti.df <- cbind("sentiment" = rownames(senti.df), senti.df)
  rownames(senti.df) <- NULL
  highchart() %>%
    hc_title(text = "Emotion Indicator") %>%
    hc_chart(polar = T) %>% 
    hc_xAxis(categories = senti.df$sentiment, 
             labels = list(style = list(fontSize= '14px')), title =NULL, tickmarkPlacement = "on", lineWidth = 0) %>% 
    hc_plotOptions(series = list(marker = list(enabled = F))) %>% 
    hc_yAxis(gridLineInterpolation = "polygon", lineWidth = 0, min = 0) %>% 
    hc_add_series(name = "Emotions Score", senti.df$number, type ="area", color = "#56A5EC", pointPlacement = "on")
}

plot_hist <- function(clean.tweets.dataframe){
  t <- tweet.corpus %>%
    mutate(structure_type = case_when(
      str_detect(text, "fault|fallen|transformer|wire|darkness") ~ "technical",
      str_detect(text,"meter|bill|reconciliation|payment") ~ "non-technical",
      True ~ "additional review"))
  t %>%
    count(structure_type, sort =T) %>%
    mutate(structure_type = reorder(structure_type, n)) %>%
    ggplot(aes(x = structure_type, y = n)) +
    geom_col() +
    xlab(NULL) +
    coord_flip()+
    theme_classic()+
    labs(title = "Count of Complaints Types for Twitter Shares",
         subtitle = "Most frequent Complaints by structure_type", y = "Count of Tweets", x = "")
}

server <- function(input, output) {
  
  tweets <- eventReactive(input$goButton,{
    tweet.corpus(searchTwitter(input$search, n = input$num, lang = "en"))
  }) 
  
}

output$plot2 <- renderPlot({
  withProgress({
    setProgress(message = "Processing Emotions")
    plot_wordcloud(tweets())
  })
  
})  
#> Error in renderPlot({: could not find function "renderPlot"
output$plot3 <- renderPlot({
  withProgress({
    setProgress(message = "Processing Barplot")
    plot_hist(tweets())
  })
  
})
#> Error in renderPlot({: could not find function "renderPlot"

Created on 2020-08-04 by the reprex package (v0.3.0)

First thing for you to think about is that you define two functions, they both consume a parameter ,
clean.tweets.dataframe. but neither use it in their function bodies. Probably this clean.tweets.dataframe name is what you want to really manipulate in the function.

I was calling the wrong argument from the function. Thanks for pointing that out.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.