title: Error in as.double(y) : cannot coerce type 'environment' to vector of type 'double' in ggplot command in R
body: <p>I am trying to make a plot between two different variables (RodC independent varaible and TickPrev dependent varaible) using the ggplot command. I have the following packages installed: pacman, party, rio, tidyverse,dplyr,MASS.</p>
  <pre><code>gg1314 &lt;- ggplot(df1314, aes(RodC, TickPrev, color=YearS)) +
    geom_jitter() + 
    labs(title = &quot;Tick Prevalence vs Captured Rodents 2013-2014&quot;, 
         x=&quot;Tick Prevalence (%)&quot;, 
         y=&quot;Nº of Captured Rodents&quot;) + 
    scale_color_discrete(name=&quot;YearSeason&quot;)
  </code></pre>
  <p>The code above worked perfectly fine, but when I deleted a few rows to conduct a similar analysis with the same variables, the code start to give the following error:</p>
  <pre><code>ggNBS &lt;- ggplot(dfNBS, aes(RodC, TickPrev, colors=Year)) + 
    geom_jitter() + 
    labs(title = &quot;Tick Prevalence vs Captured Rodents NBS&quot;, 
         x=&quot;Tick prevalence (%)&quot;, 
         y=&quot;Nº of captured rodents&quot;) + 
    scale_color_discrete(name=&quot;Year&quot;) 
  </code></pre>
  <blockquote>
  <p>Error in as.double(y) :    cannot coerce type 'environment' to vector
  of type 'double'</p>
  </blockquote>
  <p>The only difference between the dataframes is that I eliminated some rows. But the variables remained the same.</p>
  <p><a href="https://i.stack.imgur.com/1GqQa.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>How can I solve this.
  Thank you very much</p>
  <p>Image from df1314. dfNBS is the same, but in the MiceS and YearS it only contains information that had NBS or NBS2.</p>