# NOT RUN {
library(ggplot2)
library(sf)
library(dplyr)
# Convert all 2008 plot stems to sf object
census_2008_bw_sf <- census_2008_bw %>%
st_as_sf(coords = c("gx", "gy"))
# Plot stems with plot boundary
ggplot() +
geom_sf(data = census_2008_bw_sf, size = 0.25)
# Species-specific mortality between 2008 and 2014 censuses
census_2008_bw %>%
left_join(census_2014_bw, by = c("treeID", "stemID"), suffix = c("_2008", "_2014")) %>%
mutate(mortality = ifelse(is.na(dbh_2014), 1, 0)) %>%
group_by(sp_2008) %>%
summarize(mortality = mean(mortality), n = n()) %>%
arrange(desc(n))
# }
Run the code above in your browser using DataLab