title: I'm building a Shiny app in R and keep getting an error that says "Warning: Error in +: non-numeric argument to binary operator"
body: <p>I'm creating a Shiny app in R but every time I try to load it i get the error "non-numeric argument to binary operator" - this error seems to be occurring in the renderPlot section in the server area.</p>
  
  <p>I'm in the preliminary stages of building this and I'm not an expert in Shiny by any means. The app is supposed to load a chart based on the values from the projections that I'm scraping from FantasyPros. It was working when I was using regular data (as opposed to reactive data), but I can't seem to nail down the reactive part. Any help is appreciated!</p>
  
  <pre><code>if(interactive()){
  
          ## load required packages
          library(shiny)
          library(tidyverse)
          library(ggplot2)
          library(ggrepel)
          library(dplyr)
          library(agridat)
          library(rvest)
          library(tidyr)
  
          ## load latest projections from fantasypros
          scrape_projections &lt;- function(position, week) {
  
              if (position == "qb") {
                  naming &lt;- c("", "PASS", "PASS", 'PASS', "PASS", "PASS", "RUSH", "RUSH", "RUSH", "", "")
              } else if (position == "rb") {
                  naming &lt;-  c("", "RUSH", "RUSH", "RUSH", "REC", "REC","REC", "", "")
              } else if (position == "wr") {
  
                  naming &lt;- c("", "REC", "REC","REC", "RUSH", "RUSH", "RUSH", "", "")
              } else {
                  naming &lt;- c("", "REC", "REC","REC", "", "")
              }
  
              # Be nice
              Sys.sleep(1)
  
              message(glue::glue("Scraping projected stats for {position} wk: {week}!"))
  
              url &lt;- glue::glue("https://www.fantasypros.com/nfl/projections/{position}.php?week=draft")
  
              url %&gt;%
                  read_html() %&gt;% 
                  html_table() %&gt;% 
                  .[[1]] %&gt;% 
                  filter(X1 != "") %&gt;%
                  set_names(nm = .[1,]) %&gt;%
                  .[2:length(.$Player),] %&gt;% 
                  set_names(., paste({naming}, names(.), sep = "_")) %&gt;% 
                  rename("Player" = "_Player", "FL" = "_FL", "FPTS" = "_FPTS") %&gt;% 
                  mutate(position = toupper({position}),
                         week = week) %&gt;% 
                  mutate(team = str_sub(Player, -3),
                         team = str_extract(team, "[[:upper:]]+"),
                         Player = str_remove(Player, team),
                         Player = str_trim(Player)) %&gt;% 
                  select(Player, team, position, week, everything()) %&gt;%
                  rename_all(tolower)
          }
  
          # define inputs
          position &lt;- c("qb", "rb", "wr", "te")
          week &lt;- "draft"
  
          # crossing for all combos of inputs
          crossing(position, week)
  
          # scrape the data
          projections &lt;- crossing(position = position, week = week) %&gt;% 
              pmap_dfr(scrape_projections) %&gt;%
              mutate_at(vars(pass_yds, rush_yds, rec_yds), str_remove, ",") %&gt;% 
              mutate_at(vars(pass_att:rec_tds), as.numeric) %&gt;%
              mutate_at(vars(team:position), as.factor) %&gt;% 
              select(-c("week")) %&gt;% 
              as_tibble()
  
          ## set all NA values to 0
          projections[is.na(projections)] = 0
  
          ## set_vor function
          set_vor &lt;- function(points_table, vor_baseline = NULL, vor_var = c("fpts", "floor", "ceiling")){
              if(is.null(vor_baseline))
                  vor_baseline &lt;- default_baseline
  
              vor_var &lt;- match.arg(vor_var)
  
              vor_tbl &lt;- select(points_table, "player", "position", vor_var) %&gt;%
                  rename(vor_var = !!vor_var) %&gt;% group_by(position) %&gt;%
                  mutate(vor_rank = dense_rank(-vor_var), vor_base = vor_baseline[position]) %&gt;%
                  filter(vor_rank &gt;= vor_base - 1 &amp;  vor_rank &lt;= vor_base + 1)  %&gt;%
                  summarise(vor_base = mean(vor_var)) %&gt;%  ungroup() %&gt;%
                  select(position, vor_base) %&gt;% inner_join(points_table, by = c("position")) %&gt;%
                  rename(vor_var = !!vor_var) %&gt;%
                  mutate(vor = vor_var - vor_base,
                         rank = dense_rank(-vor), !!vor_var := vor_var) %&gt;%
                  select(player, position, vor, rank) %&gt;% rename_if(is.numeric, funs(paste(vor_var, ., sep = "_"))) %&gt;%
                  ungroup()
  
              return(vor_tbl)
          }
  
  
          ## 
          ## ui.R: defines a layout that will resize according to the size of the browser window; 
          ##       all the app code will be placed within the brackets of this
  
          ui &lt;- fluidPage(
              titlePanel("2020 Fantasy Football Draft Evaluator - created by Sam Hoppen"),
              sidebarLayout(
                  sidebarPanel(
                      p("Select draft settings"),
                      selectInput(inputId = "league_size",
                                  label = "1. Select league size",
                                  choices = c("8", "10", "12", "14", "16"), selected = "12"),
                      selectInput(inputId = "draft_position",
                                  label = "2. Select draft position",
                                  choices = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"), selected = "1"),
                      radioButtons(inputId = "scoring",
                                   label = "3. Select scoring type",
                                   choices = c("Non PPR", "Half PPR", "Full PPR"), selected = "Half PPR"),
                      tags$p("Select starting lineup"),
                      radioButtons(inputId = "starting_qbs",
                                  label = "Number of starting QBs",
                                  choices = c("0", "1", "2", "3", "4", "5", "6"),
                                  selected = "1",
                                  inline = TRUE),
                      radioButtons(inputId = "starting_rbs",
                                  label = "Number of starting RBs",
                                  choices = c("0", "1", "2", "3", "4", "5", "6"),
                                  selected = "2",
                                  inline = TRUE),
                      radioButtons(inputId = "starting_wrs",
                                  label = "Number of starting WRs",
                                  choices = c("0", "1", "2", "3", "4", "5", "6"),
                                  selected = "3",
                                  inline = TRUE),
                      radioButtons(inputId = "starting_tes",
                                  label = "Number of starting TEs",
                                  choices = c("0", "1", "2", "3", "4", "5", "6"),
                                  selected = "1",
                                  inline = TRUE),
                      radioButtons(inputId = "starting_flex",
                                  label = "Number of starting flex spots",
                                  choices = c("0", "1", "2", "3", "4", "5", "6"),
                                  selected = "1",
                                  inline = TRUE),
                      radioButtons(inputId = "starting_superflex",
                                  label = "Number of starting superflex spots",
                                  choices = c("0", "1", "2", "3", "4", "5", "6"),
                                  selected = "0",
                                  inline = TRUE),
                      radioButtons(inputId = "bench_players",
                                   label = "Number of bench spots",
                                   choices = c("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"),
                                   selected = "6",
                                   inline = TRUE),
      #                actionButton(inputId = "draft",
      #                             label = "Click to begin drafting!"),
                      selectInput("draft_pick_1",
                                  "Round 1 Selection",
                                  c("Select player" ="", projections$player)),
      selectInput("draft_pick_2",
                  "Round 2 Selection",
                  c("Select player" ="", projections$player)),
      selectInput("draft_pick_3",
                  "Round 3 Selection",
                  c("Select player" ="", projections$player)),
      selectInput("draft_pick_4",
                  "Round 4 Selection",
                  c("Select player" ="", projections$player)),
      selectInput("draft_pick_5",
                  "Round 5 Selection",
                  c("Select player" ="", projections$player)),
      selectInput("draft_pick_6",
                  "Round 6 Selection",
                  c("Select player" ="", projections$player)),
      selectInput("draft_pick_7",
                  "Round 7 Selection",
                  c("Select player" ="", projections$player)),
      selectInput("draft_pick_8",
                  "Round 8 Selection",
                  c("Select player" ="", projections$player)),
      selectInput("draft_pick_9",
                  "Round 9 Selection",
                  c("Select player" ="", projections$player)),
      selectInput("draft_pick_10",
                  "Round 10 Selection",
                  c("Select player" ="", projections$player)),
      selectInput("draft_pick_11",
                  "Round 11 Selection",
                  c("Select player" ="", projections$player)),
      selectInput("draft_pick_12",
                  "Round 12 Selection",
                  c("Select player" ="", projections$player)),
      selectInput("draft_pick_13",
                  "Round 13 Selection",
                  c("Select player" ="", projections$player)),
      selectInput("draft_pick_14",
                  "Round 14 Selection",
                  c("Select player" ="", projections$player)),
      selectInput("draft_pick_15",
                  "Round 15 Selection",
                  c("Select player" ="", projections$player))
                  ),
                  mainPanel(
                      plotOutput("draftPlot")
                  )
              )
          )
  
          ## server
          server &lt;- function(input, output) {
              #            input$draft
              #            isolate(
              default_baseline &lt;- reactive(
                  c(QB = (input$league_size*(input$starting_qbs + input$starting_superflex)*1.25),
                    RB = ((input$league_size*(input$starting_rbs + input$starting_flex)*1.5) + (input$starting_superflex*input$league_size*0.5)),
                    WR = ((input$league_size*(input$starting_wrs + input$starting_flex)*1.5) + (input$starting_superflex*input$league_size*0.5)),
                    TE = ((input$league_size*(input$starting_tes +(input$starting_flex*0.5))) + (input$starting_superflex*input$league_size*0.25)),
                    DST = (input$league_size*0.5),
                    K = (input$league_size*0.25)))
  
                  vor_table &lt;- reactive(
                      set_vor(projections,
                                       vor_baseline = default_baseline(),
                                       vor_var = "fpts"))
              #            drafted_players &lt;- projections %&gt;% 
              #                filter(player = c(input$draft_pick_1,
              #                                  ))
              output$draftPlot &lt;- renderPlot({
                  ggplot() +
                      geom_smooth(data = vor_table(),
                                  aes(x = as.numeric(fpts_rank), y = as.numeric(fpts_vor)),
                                  color = "firebrick",
                                  linetype = "dashed",
                                  size = 1,
                                  method = "loess",
                                  formula = y ~ x,
                                  se = FALSE) +
                      coord_cartesian(xlim = c(0, 200),
                                      ylim = c(0, 150)) +
                      labs(x = "Player Draft Selection",
                           y = "Player Value Over Replacement",
      #                     caption = "Data from nflscrapR",
                           title = "2020 Fantasy Football Draft Evaluator",
                           subtitle = "Created by @SamHoppen") +
                      theme_bw()
              })
          }
      }
  
      ## run app
      shinyApp(ui = ui, server = server)
  </code></pre>