Shiny App R;不接受输入

时间:2018-05-31 00:42:43

标签: r filter shiny

我正在尝试编写一个闪亮的应用程序而我遇到了麻烦。我的目标:创建一个以年份为输入的文字云。现在它是每年打印相同的单词表明它没有接受输入,任何想法如何解决这个问题?非常感谢!

这是我的ui.R文件:

library(shiny)

ui <- fluidPage(
  # App title
  headerPanel("Word Cloud"),
  # Sidebar panel for inputs
  sidebarPanel(
    #using the select input function to have users choose a year
    selectInput("year","Choose a Year:",
                choices = NYT_tokens_freq$Year),
    #actionButton("update", "Change"),
    hr(),
    sliderInput("maximum","Max. Number of Words",
                min=1, max=20, value=100)
  ),
  # Main panel for displaying outputs
  mainPanel(
    plotOutput("wmplot")
  )
)

这是我的server.R文件:

library(shiny)
library(tm)
library(wordcloud)
library(tidyverse)

NYT_tokens <- read.csv("NYT_tokens_freq.csv")

server <- function(input, output) {
  terms <- reactive({
  input$year
  })



  output$wmplot <- renderPlot({
    NYT_tokens_freq%>%
    filter(Year == input$year)
    wordcloud(words = NYT_tokens_freq$word, scale= c(1,0.5),
                max.words=input$maximum, random.order=FALSE,
                colors=brewer.pal(5, "Dark2"))
  })
  }

0 个答案:

没有答案