Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute joins not working with sf-tibble #414

Closed
dpprdan opened this issue Jul 12, 2017 · 1 comment
Closed

Attribute joins not working with sf-tibble #414

dpprdan opened this issue Jul 12, 2017 · 1 comment

Comments

@dpprdan
Copy link
Contributor

dpprdan commented Jul 12, 2017

Attribute joins do not work with sf-tibble, i.e. class c("sf", "tbl_df", "tbl", "data.frame")

library("dplyr", warn.conflicts = FALSE)
library("sf")
#> Linking to GEOS 3.6.1, GDAL 2.2.0, proj.4 4.9.3
nc_sf <- st_read(system.file("shape/nc.shp", package="sf"), quiet = TRUE) 
class(nc_sf)
#> [1] "sf"         "data.frame"

Actually, shouldn't this already be a sf-tibble?

Anyway, the join works

nc_df <- nc_sf %>% st_set_geometry(NULL)
nc2 <- left_join(nc_sf, nc_df, by = "FIPS")

With an sf-tibble, it does not

class(nc_sf) <- c("sf", "tbl_df", "tbl", "data.frame")
left_join(nc_sf, nc_df, by = "FIPS")
#> Error in .subset2(x, i, exact = exact): attempt to select less than one element in get1index
Session info
devtools::session_info()
#> Session info -------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.4.1 (2017-06-30)
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  German_Germany.1252         
#>  tz       Europe/Berlin               
#>  date     2017-07-12
#> Packages -----------------------------------------------------------------
#>  package    * version date       source                         
#>  assertthat   0.2.0   2017-04-11 CRAN (R 3.3.3)                 
#>  backports    1.1.0   2017-05-22 CRAN (R 3.4.0)                 
#>  base       * 3.4.1   2017-06-30 local                          
#>  bindr        0.1     2016-11-13 CRAN (R 3.4.0)                 
#>  bindrcpp     0.2     2017-06-17 CRAN (R 3.4.0)                 
#>  compiler     3.4.1   2017-06-30 local                          
#>  datasets   * 3.4.1   2017-06-30 local                          
#>  DBI          0.7     2017-06-18 CRAN (R 3.4.0)                 
#>  devtools     1.13.2  2017-06-02 CRAN (R 3.4.0)                 
#>  digest       0.6.12  2017-01-27 CRAN (R 3.3.2)                 
#>  dplyr      * 0.7.1   2017-06-22 CRAN (R 3.4.0)                 
#>  evaluate     0.10.1  2017-06-24 CRAN (R 3.4.0)                 
#>  glue         1.1.1   2017-06-21 CRAN (R 3.4.0)                 
#>  graphics   * 3.4.1   2017-06-30 local                          
#>  grDevices  * 3.4.1   2017-06-30 local                          
#>  grid         3.4.1   2017-06-30 local                          
#>  htmltools    0.3.6   2017-04-28 CRAN (R 3.4.0)                 
#>  knitr        1.16    2017-05-18 CRAN (R 3.4.0)                 
#>  magrittr     1.5     2014-11-22 CRAN (R 3.3.0)                 
#>  memoise      1.1.0   2017-05-29 Github (hadley/memoise@e372cde)
#>  methods    * 3.4.1   2017-06-30 local                          
#>  pkgconfig    2.0.1   2017-03-21 CRAN (R 3.4.0)                 
#>  R6           2.2.2   2017-06-17 CRAN (R 3.4.0)                 
#>  Rcpp         0.12.11 2017-05-22 CRAN (R 3.4.0)                 
#>  rlang        0.1.1   2017-05-18 CRAN (R 3.4.0)                 
#>  rmarkdown    1.6     2017-06-15 CRAN (R 3.4.0)                 
#>  rprojroot    1.2     2017-01-16 CRAN (R 3.3.2)                 
#>  sf         * 0.5-2   2017-07-12 Github (r-spatial/sf@e75613f)  
#>  stats      * 3.4.1   2017-06-30 local                          
#>  stringi      1.1.5   2017-04-07 CRAN (R 3.3.3)                 
#>  stringr      1.2.0   2017-02-18 CRAN (R 3.3.3)                 
#>  tibble       1.3.3   2017-05-28 CRAN (R 3.4.0)                 
#>  tools        3.4.1   2017-06-30 local                          
#>  udunits2     0.13    2016-11-17 CRAN (R 3.3.2)                 
#>  units        0.4-5   2017-06-15 CRAN (R 3.4.0)                 
#>  utils      * 3.4.1   2017-06-30 local                          
#>  withr        1.0.2   2016-06-20 CRAN (R 3.3.1)                 
#>  yaml         2.1.14  2016-11-12 CRAN (R 3.3.2)
@edzer edzer closed this as completed in f7d736e Jul 13, 2017
@dpprdan
Copy link
Contributor Author

dpprdan commented Jul 14, 2017

👍

In case someone stumbles over "Actually, shouldn't this already be a sf-tibble?": Nevermind, I mixed up st_read (which returns an sf-dataframe) and read_sf (which returns a sf-tibble as of v0.5-2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant