0

我有一个闪亮的应用程序正在查看新闻文章的情绪分析。作为其中的一部分,我使用感测器函数get_sentences()sentiment(). 当我在控制台中运行此代码时,它工作正常,但是当我尝试通过闪亮运行它时,我得到了错误Error in mutate_impl: Evaluation error: unused argument (.x)

相关代码为:

ui <- fluidPage(
  useShinyjs(),
  sidebarLayout(
    sidebarPanel(
      ...
    mainPanel(
      tabsetPanel(type = "tab",
        ...
        tabPanel("Sentiment", 
           selectInput(inputId = "sourceSelect", label = "Media Source", sources$title),
           plotOutput("sentiment"),
         )
      )
    )
  )
)

server <- function(input, output) {

  ...

  output$sentiment <- renderPlot(
    sentiment()
  )
  sentiment <-eventReactive(input$sourceSelect, {
    max_min = getMinMax(input)
    min = max_min[1]
    max = max_min[2]
    news1 <- news %>%
      filter(isDuplicate == "FALSE") %>%
      filter(date < max) %>%
      filter(date > min) %>%
      mutate(id = seq(1, nrow(.), 1))  %>%
      mutate(selectedSource = str_detect(title, input$sourceSelect)) %>%
      select(date, body, source, title, id, selectedSource)
    news_sentiment <- news1 %>%
      mutate(sentences = map(body, ~(get_sentences(.x))), (sentiment = map(sentences, ~(sentiment(.x)))))
    ...
})
...

}


shinyApp(ui = ui, server = server)

随着错误发生就mutate(sentences = map(body, ~(get_sentences(.x))), (sentiment = map(sentences, ~(sentiment(.x)))))行了。

当我通过控制台运行它时,它不会抛出错误并且工作正常,创建一个包含一sentences列的数据框,以及一个sentiment包含相关列表的列(来自感测器函数的正确输出)。我已经测试过,在控制台和闪亮版本中,传递到该管道的帧是相同的。我怀疑与使用闪亮的map调用可能有一些关系。(.x)

4

1 回答 1

0

我发现了错误,它是函数被调用sentiment并且还试图sentimentsentimentr库中调用。一旦我将所有这些重命名为不同的,它就起作用了。

于 2019-01-17T12:07:40.437 回答