Running ‘aggregate.R’ [1s/1s]
  Comparing ‘aggregate.Rout’ to ‘aggregate.Rout.save’ ...4c4
< Linking to GEOS 3.5.1, GDAL 2.2.2, proj.4 4.9.3
---
> Linking to GEOS 3.5.1, GDAL 2.2.0, proj.4 4.9.2
  Running ‘cast.R’ [1s/1s]
  Comparing ‘cast.Rout’ to ‘cast.Rout.save’ ... OK
  Running ‘crs.R’ [1s/1s]
  Comparing ‘crs.Rout’ to ‘crs.Rout.save’ ... OK
  Running ‘dist.R’ [2s/2s]
  Comparing ‘dist.Rout’ to ‘dist.Rout.save’ ... OK
  Running ‘dplyr.R’ [3s/3s]
Running the tests in ‘tests/dplyr.R’ failed.
Complete output:
  > suppressPackageStartupMessages(library(sf))
  > library(dplyr)
  
  Attaching package: 'dplyr'
  
  The following objects are masked from 'package:stats':
  
      filter, lag
  
  The following objects are masked from 'package:base':
  
      intersect, setdiff, setequal, union
  
  > nc = st_read(system.file("shape/nc.shp", package="sf"), quiet = TRUE)
  > nc %>% filter(AREA > .1) %>% plot()
  Warning message:
  plotting the first 10 out of 14 attributes; use max.plot = 14 to plot all 
  > 
  > # plot 10 smallest counties in grey:
  > nc %>% 
  +   select(BIR74, geometry) %>% 
  +   plot()
  > 
  > nc %>% 
  +   select(AREA, geometry) %>% 
  +   arrange(AREA) %>% 
  +   slice(1:10) %>% 
  +   plot(add = TRUE, col = 'grey', main ="")
  > 
  > # select: check both when geometry is part of the selection, and when not:
  > nc %>% select(SID74, SID79) %>% names()
  [1] "SID74"    "SID79"    "geometry"
  > nc %>% select(SID74, SID79, geometry) %>% names()
  [1] "SID74"    "SID79"    "geometry"
  > nc %>% select(SID74, SID79) %>% class()
  [1] "sf"         "data.frame"
  > nc %>% select(SID74, SID79, geometry) %>% class()
  [1] "sf"         "data.frame"
  > 
  > # group_by:
  > nc$area_cl = cut(nc$AREA, c(0, .1, .12, .15, .25))
  > nc %>% group_by(area_cl) %>% class()
  [1] "sf"         "grouped_df" "tbl_df"     "tbl"        "data.frame"
  > 
  > # mutate:
  > nc2 <- nc %>% mutate(area10 = AREA/10)
  > 
  > # transmute:
  > nc %>% transmute(AREA = AREA/10, geometry = geometry) %>% class()
  [1] "sf"         "data.frame"
  > nc %>% transmute(AREA = AREA/10) %>% class()
  [1] "sf"         "data.frame"
  > 
  > # rename:
  > nc2 <- nc %>% rename(area = AREA)
  > 
  > # distinct:
  > nc[c(1:100,1:10),] %>% distinct() %>% nrow()
  [1] 100
  > 
  > # summarize:
  > nc$area_cl = cut(nc$AREA, c(0, .1, .12, .15, .25))
  > nc.g <- nc %>% group_by(area_cl)
  > nc.g %>% summarise(mean(AREA))
  Simple feature collection with 4 features and 2 fields
  geometry type:  MULTIPOLYGON
  dimension:      XY
  bbox:           xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965
  epsg (SRID):    4267
  proj4string:    +proj=longlat +datum=NAD27 +no_defs
  # A tibble: 4 x 3
        area_cl `mean(AREA)`          geometry
         <fctr>        <dbl>  <simple_feature>
  1     (0,0.1]   0.07602857 <MULTIPOLYGON...>
  2  (0.1,0.12]   0.11206667 <MULTIPOLYGON...>
  3 (0.12,0.15]   0.13422727 <MULTIPOLYGON...>
  4 (0.15,0.25]   0.19039286 <MULTIPOLYGON...>
  > nc.g %>% summarize(mean(AREA)) %>% plot(col = 3:6/7)
  > 
  > library(tidyr)
  > 
  > # time-wide to long table, using tidyr::gather
  > # stack the two SID columns for the July 1, 1974 - June 30, 1978 and July 1, 1979 - June 30, 1984 periods
  > # (see https://cran.r-project.org/web/packages/spdep/vignettes/sids.pdf)
  > nc %>% select(SID74, SID79, geometry) %>% gather(VAR, SID, -geometry) %>% summary()
  Error in melt_dataframe(data, id_idx - 1L, gather_idx - 1L, as.character(key_var),  : 
    STRING_PTR() can only be applied to a 'character', not a 'list'
  Calls: %>% ... <Anonymous> -> gather.data.frame -> melt_dataframe -> .Call
  Execution halted