小编Mat*_*shy的帖子

Shiny 的反应式 DateRangeInput

我正在自学 Shiny,但我被困在 ggplot2 图上,无法使用反应式 dateRangeInput 作为我的 x 轴。我有几个问题:

  1. 有没有办法使用我的数据框来获取日期范围输入的最小值、最大值,而不必对它们进行硬编码,以便当我向数据框添加更多推文时,我不必每次都对这些值进行硬编码?
  2. 我收到错误:Aesthetics must be either length 1 or the same as the data (33108): x, y当我尝试使用 input$date 作为我的 aes(x = input$date...

library(shiny)
library(tidyr)
library(ggplot2)

tweets <- read.csv(file.choose())
colnames(tweets)[1] <- "Content"
tweets <- separate(tweets, created_at, c("Date", "Time"), sep = " ")
tweets$Date <-as.Date(tweets$Date, "%m/%d/%Y")

ui <- fluidPage(
  dateRangeInput(inputId = "date", 
              strong("Date Range"),
              start = "2009-05-04", end = "2018-02-28",
              min = "2009-05-04", max ="2018-02-28" ),
  plotOutput("Graph")
)

server <- function(input, output) { …
Run Code Online (Sandbox Code Playgroud)

r ggplot2 shiny

2
推荐指数
1
解决办法
7342
查看次数

标签 统计

ggplot2 ×1

r ×1

shiny ×1