Skip to content

Errors running spdplyr example

2 messages · Shige Song, Michael Sumner

#
Dear All,

When I tried to run the following code (taken from the *spdplyr* package
vignettes):

library(spdplyr)
library(maptools)
data(wrld_simpl)

worldcorner <- wrld_simpl %>%
  mutate(lon = coordinates(wrld_simpl)[,1], lat =
coordinates(wrld_simpl)[,2]) %>%
  filter(lat < -20, lon > 60) %>%
  dplyr::select(NAME)


I got the following error messages:

Error in (function (cl, name, valueClass)  :
  c("assignment of an object of class ?tbl_df? is not valid for @?data? in
an object of class ?SpatialPolygonsDataFrame?; is(value, \"data.frame\") is
not TRUE", "assignment of an object of class ?tbl? is not valid for @?data?
in an object of class ?SpatialPolygonsDataFrame?; is(value, \"data.frame\")
is not TRUE", "assignment of an object of class ?data.frame? is not valid
for @?data? in an object of class ?SpatialPolygonsDataFrame?; is(value,
\"data.frame\") is not TRUE")

I am running R 3.3.3 with the latest CRAN version of *spdplyr* (0.1.3) on
Windows 10.

Thanks.

Best,
Shige
#
On Wed, 7 Jun 2017 at 17:29 Shige Song <shigesong at gmail.com> wrote:

            
Hi Shige,

I can't reproduce this, could you run 'sessionInfo()' and let me know?

I'm pretty sure you could workaround this by running

setOldClass( c("tbl_df", "tbl", "data.frame" ) )

but I don't understand why that's not already working, and it's not
something you want to rely on. (You are only the second report where I've
heard anyone seeing this, it's because sp is strict about only accepting
'data.frame' rather than anything inheriting from 'data.frame', as 'tbl_df'
does. )

Feel free to take this off-list and post directly to the Issues on Github
or email me.

 bug.report(package = "spdplyr")

Cheers, Mike.