# helper functions
#function used to extract variable from sf dataframe with the variable name
get_var <- function(vname,df) {
v <- df[vname] %>% st_set_geometry(NULL)
v <- unname(v[,1])
return(v)
}
#function used to contruct the correct palette for a set of classification
match_palette <- function(patterns, classifications, colors){
classes_present <- base::unique(patterns)
mat <- matrix(c(classifications,colors), ncol = 2)
logi <- classifications %in% classes_present
pre_col <- matrix(mat[logi], ncol = 2)
pal <- pre_col[,2]
return(pal)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.