ggplotly和闪亮-顺序错误:参数1不是向量

问题描述

你好, 我是刚开始使用R进行编码并使用Tidy Tuesday数据集来构建闪亮的应用(https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-04-07/tdf_winners.csv)。

我收到一条错误消息:“错误顺序:参数1不是向量”,并且通过“国籍”列缩小了错误范围。这是我的数据集的列(我从start_date列使用lubridate创建了year_raw列):

[1] "edition" "start_date" "winner_name" "winner_team" "distance" "time_overall"
[7] "time_margin" "stage_wins" "stages_led" "height" "weight" "age"
[13] "born" "died" "full_name" "nickname" "birth_town" "birth_country" 
[19] "nationality" "year_raw"

以下是我认为错误的sever.R代码块:

shinyServer(function(input,output) {

output$plot <- renderPlotly({
    
    ds <- tdf_winners_years %>%
        filter(year_raw >= input$startyear,year_raw <= input$endyear,nationality %in% input$nationalities)
    
    ggplot.plot <- ggplot(ds,aes(x = year_raw,y = time_overall,color = nationality)) +
        geom_line(size = 0.5)
    
    ggplotly(ggplot.plot)

以下是相应的ui.R代码块:

numericInput(inputId = "startyear",label = "Enter starting year",value = 1960,min = 1903,max = 2019,step = 1),numericInput(inputId = "endyear",label = "Enter ending year",value = 1970,checkboxGroupInput(inputId = "nationalities",label = "Nationalities to display",sort(unique(nationality_unique)),selected = c('France','Luxembourg'))

当我分别键入过滤器功能的每个部分时,我发现错误在于:

filter(nationality %in% input$nationalities)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)