require(rangeMapper)
require(data.table)
con = rmap_connect()
wrens = read_wrens()
rmap_add_ranges(con, x = wrens, ID = 'sci_name')
rmap_prepare(con, 'hex', cellsize=500)
rmap_save_map(con) # default is a species_richness map.
rmap_add_bio(con, wrens, 'sci_name')
rmap_save_map(con, fun='avg', src='wrens',v='body_mass', dst='avg_bodymass')
rmap_save_subset(con,dst ='ss1', species_richness = 'species_richness > 10')
rmap_save_map(con,subset = 'ss1', dst ='sr2')
rmap_save_map(con, fun='avg', src='wrens',v='body_mass',
subset='ss1', dst='avg_bodymass_high_SR')
rmap_save_map(con, fun= mean, na.rm = TRUE, src='wrens',
v='body_mass', dst='mean_bodymass')
Median = function(x) median(x,na.rm = TRUE)
rmap_save_map(con, fun = Median, src='wrens',
v='body_mass', dst='median_bodymass')
rmap_save_map(con, fun= mean, na.rm = TRUE, src='wrens',v='body_mass',
subset='ss1', dst='mean_bodymass_high_SR')
linmod = function(x) {
lm(clutch_size ~ log(female_tarsus), x) %>%
summary %>% coefficients %>% data.table %>% .[-1] }
rmap_save_map(con, fun= linmod, src='wrens', dst='slope_clutch_size')
data(dem)
rmap_save_map(con, fun= 'mean', src= dem , dst='dem', progress = FALSE)
x = rmap_to_sf(con)
dbDisconnect(con)
Run the code above in your browser using DataLab