
Last chance! 50% off unlimited learning
Sale ends in
Dplyr verb methods for sf objects. Geometries are sticky, use as.data.frame to let codedplyr's own methods drop them.
filter_.sf(.data, ..., .dots)filter.sf(.data, ...)
arrange_.sf(.data, ..., .dots)
arrange.sf(.data, ...)
distinct_.sf(.data, ..., .dots, .keep_all = FALSE)
distinct.sf(.data, ..., .dots, .keep_all = FALSE)
group_by_.sf(.data, ..., .dots, add = FALSE)
group_by.sf(.data, ..., .dots, add = FALSE)
ungroup.sf(x, ...)
mutate_.sf(.data, ..., .dots)
mutate.sf(.data, ..., .dots)
transmute_.sf(.data, ..., .dots)
transmute.sf(.data, ..., .dots)
select_.sf(.data, ..., .dots = NULL)
select.sf(.data, ...)
rename_.sf(.data, ..., .dots)
rename.sf(.data, ...)
slice_.sf(.data, ..., .dots)
slice.sf(.data, ...)
summarise.sf(.data, ..., .dots, do_union = TRUE)
summarise_.sf(.data, ..., .dots, do_union = TRUE)
gather_.sf(data, key_col, value_col, gather_cols, na.rm = FALSE,
convert = FALSE, factor_key = FALSE)
spread_.sf(data, key_col, value_col, fill = NA, convert = FALSE,
drop = TRUE, sep = NULL)
sample_n.sf(tbl, size, replace = FALSE, weight = NULL,
.env = parent.frame())
sample_frac.sf(tbl, size = 1, replace = FALSE, weight = NULL,
.env = parent.frame())
nest_.sf(data, key_col, nest_cols)
inner_join.sf(x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ...)
left_join.sf(x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ...)
right_join.sf(x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ...)
full_join.sf(x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ...)
semi_join.sf(x, y, by = NULL, copy = FALSE, ...)
anti_join.sf(x, y, by = NULL, copy = FALSE, ...)
data object of class sf
other arguments
see corresponding function in package dplyr
see corresponding function in dplyr
see corresponding function in dplyr
see left_join
logical; should geometries be unioned by using st_union, or simply be combined using st_combine? Using st_union resolves internal boundaries, but in case of unioning points may also change the order of the points.
see original function docs
see original function docs
see original function docs
see original function docs
see original function docs
see original function docs
see original function docs
see original function docs
see original function docs
see original function docs
see original function docs
see original function docs
see original function docs
see original function docs
see original function docs
see nest
see left_join
see left_join
see left_join
see left_join
select
keeps the geometry regardless whether it is selected or not; to deselect it, first pipe through as.data.frame
to let dplyr's own select
drop it.
library(dplyr)
nc = st_read(system.file("shape/nc.shp", package="sf"))
nc %>% filter(AREA > .1) %>% plot()
# plot 10 smallest counties in grey:
st_geometry(nc) %>% plot()
nc %>% select(AREA) %>% arrange(AREA) %>% slice(1:10) %>% plot(add = TRUE, col = 'grey')
title("the ten counties with smallest area")
nc[c(1:100, 1:10), ] %>% distinct() %>% nrow()
nc$area_cl = cut(nc$AREA, c(0, .1, .12, .15, .25))
nc %>% group_by(area_cl) %>% class()
nc2 <- nc %>% mutate(area10 = AREA/10)
nc %>% transmute(AREA = AREA/10, geometry = geometry) %>% class()
nc %>% transmute(AREA = AREA/10) %>% class()
nc %>% select(SID74, SID79) %>% names()
nc %>% select(SID74, SID79, geometry) %>% names()
nc %>% select(SID74, SID79) %>% class()
nc %>% select(SID74, SID79, geometry) %>% class()
nc2 <- nc %>% rename(area = AREA)
nc %>% slice(1:2)
nc$area_cl = cut(nc$AREA, c(0, .1, .12, .15, .25))
nc.g <- nc %>% group_by(area_cl)
nc.g %>% summarise(mean(AREA))
nc.g %>% summarise(mean(AREA)) %>% plot(col = grey(3:6 / 7))
nc %>% as.data.frame %>% summarise(mean(AREA))
library(tidyr)
nc %>% select(SID74, SID79, geometry) %>% gather(VAR, SID, -geometry) %>% summary()
library(tidyr)
nc$row = 1:100 # needed for spread to work
nc %>% select(SID74, SID79, geometry, row) %>%
gather(VAR, SID, -geometry, -row) %>%
spread(VAR, SID) %>% head()
Run the code above in your browser using DataLab