【发布时间】:2016-06-02 01:25:39
【问题描述】:
新手在第一个 Shiny 应用上需要一些帮助。 我想过滤几个国家并根据它绘制一个简单的折线图。但我收到错误:“评估错误:长度不正确(0),预期:110 堆栈跟踪(最内层优先)”
这里是代码。谢谢你的帮助:)
ui.r
> shinyUI(fluidPage(
> titlePanel("Die Selbstmordraten einiger OECD-Staaten"),
> sidebarLayout(
> sidebarPanel(
> checkboxGroupInput("land", "Land auswählen", choices = c ("Deutschland", "Griechenland", "Ungarn", "Litauen","Luxemburg"))
> ),
> mainPanel(
> plotOutput("plot")
> ))))
服务器.R
library(shiny)
library(ggplot2)
library(dplyr)
shinyServer(function(input, output, session) {
filter1<-reactive({
data%>%
filter(Land == input$landInput)
})
output$plot<-renderPlot({
ggplot(filter(), aes(Jahr, Rate, group=Land, colour=Land))+
geom_line(size=.5)+geom_point()+
theme(legend.title=element_blank())
})
})
【问题讨论】:
-
1) 你没有
landInput只有land2) 你可能需要%in%而不是==3) 你没有反应filter()只有filter1() -
工作正常!谢谢你,伙计:)