[R] Errors running spdplyr example

Michael Sumner mdsumner at gmail.com
Wed Jun 7 13:32:18 CEST 2017


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

> 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")
>
>
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.



> I am running R 3.3.3 with the latest CRAN version of *spdplyr* (0.1.3) on
> Windows 10.
>
> Thanks.
>
> Best,
> Shige
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia

	[[alternative HTML version deleted]]



More information about the R-help mailing list