title: R Biogeo pkg: Error in as.double(y) : cannot coerce type 'S4' to vector of type 'double'
body: <p>I am usually pretty good at figuring out error messages as long as it doesn't require much looking at the underlying code, but I am very new to working with spatial data, and can't figure this one out. </p>
  
  <p>I am using the <strong>Biogeo package</strong> with RStudio v. 0.99.903, R version 3.2.4 (2016-03-10), Windows 10 (EDIT: upgrade to newest version of R did not get rid of the error). <strong>I am currently working through the tutorial</strong> alongside trying to apply it to my own data. The function code and relevant data are on github at: <strong><a href="https://github.com/cran/biogeo" rel="nofollow noreferrer">https://github.com/cran/biogeo</a></strong> (the tutorial narrative is in the docs folder - I am at the beginning, trying to make the map on page 2). </p>
  
  <p>I am getting the following error when using the <strong>pointsworld function</strong>:</p>
  
  <pre><code>Error in as.double(y) : cannot coerce type 'S4' to vector of type 'double'
  </code></pre>
  
  <p>Related questions I found on Stack Overflow (one unanswered, one I don't really understand):</p>
  
  <p>(1) <a href="https://stackoverflow.com/questions/39911076/rstudio-error-in-as-doubley-cannot-coerce-type-s4-to-vector-of-type-doub">R: Error in as.double(y) : cannot coerce type &#39;S4&#39; to vector of type &#39;double&#39;-- raster data</a>
  (2) <a href="https://stackoverflow.com/questions/38818682/self-authored-package-load-plot-method-for-spatialpolygonsdataframe">Self-authored package: load plot method for spatialPolygonsDataFrame</a></p>
  
  <p>This is my relevant code (from the tutorial):</p>
  
  <pre><code>library(biogeo)
  data(dat) # Access the species dataset
  data(world) # Access the country boundaries
  a &lt;- pointsworld(world, dat) # basic plotting
  </code></pre>
  
  <p>I also tried the function with a subset of my own data, and received the same error. </p>
  
  <p>These are all of the packages I currently have open:</p>
  
  <pre><code>search()
  [1] ".GlobalEnv"        "package:dplyr"     "package:maptools"      "package:biogeo"    "package:raster"
  [6] "package:sp"        "tools:rstudio"     "package:stats"     "package:graphics"  "package:grDevices"
  [11] "package:utils"     "package:datasets"  "package:methods"   "Autoloads"         "package:base"     
  </code></pre>
  
  <p><code>typeof()</code> returns <code>"S4"</code> for "world" and <code>"list"</code> for dat</p>
  
  <p><code>class()</code> returns <code>"SpatialPolygonsDataFrame" attr(,"package") "sp"</code> for "world" and <code>"data.frame"</code> for "dat"</p>
  
  <p>I hope I have not overlooked something simple - I have typed and retyped the code, tried it with different data sets, tried it with the suggested (in the tutorial) map/boundaries file from ...www.thematicmapping.org/downloads/world_borders.php (take off the dots at the start, I don't have enough reputation pts to post the link), and have tried directly copy and pasting directly from the tutorial the different examples of using this function.</p>
  
  <p>Hopefully it is not just a result of me not drinking enough coffee yet - I've spent much time trying to figure this out, and am hoping somebody here can help.</p>
  
  <p>Thanks!
  Liz</p>