I'm trying to rewrite a portion of my code with the latest features from dplyr by replacing data.frame() by data_frame() and cbind() with bind_cols():
library(rgeos)
library(dplyr)
mc <- montreal %>%
gCentroid(byid=TRUE) %>%
data.frame %>%
cbind(., name = montreal[["NOM"]])
When I try to replace data.frame by data_frame I get:
Error: data_frames can only contain 1d atomic vectors and lists
And when I try to replace cbind by bind_cols I get:
Error: object at index 2 not a data.frame
Would there be a way to make this work ?
Here, montreal is a SpatialPolygonsDataframe:
GEOJSON file: http://elm.bi/limadmin.json
montreal <- readOGR("data/limadmin.json", "OGRGeoJSON")

