Dot density map help (ratios) error :could not find function "calc_dots"

#1

Hi,

I'm trying to map the census data and plotting different ethnic groups:
I'm partially following this tutorial (https://github.com/RobWHickman/sf.chlorodot)
but when I'm trying to calculate the dot positions for each column I get this error:
Error in calc_dots(df = bndukshp.df.proj.data.2017, col_names = allgroups, :
could not find function "calc_dots"

But if I use this to calculate it works but then it doesn't plot :confused:
#num.dots <- select(bndukshp.df.proj.data.2017, Arab:Asian )/1000

Any help will be much appreciated,
Thank you

0 Likes

#2

That function seems to be included in his sf.chlorodot package. If so, you will have to install that. See Rob_Hickman Git Hub

devtools::install_github('RobWHickman/sf.chlorodot')
library(sf.chlordot)
1 Like

#3

Thank you @FJCC but now I've got this error: Error in UseMethod("st_geometry") :
no applicable method for 'st_geometry' applied to an object of class "data.frame"

0 Likes

#4

I am shooting in the dark here having never used this package or sf. I notice that the last step on Robert Hickman's blog before running calc-dots is to use st_as_sf()

language_data %<>%
  #convert number of speakers to numeric
  mutate(primary_speakers = as.numeric(as.character(primary_speakers))) %>%
  #matching of area names with South African shapefile
  mutate(region = gsub(" NU", "", region)) %>%
  mutate(region = gsub("Tshwane", "City of Tshwane", region)) %>%
  #filter only the data we want to merge
  filter(region %in% south_africa$region) %>%
  filter(!is.na(language)) %>%
  filter(language != "Not applicable") %>%
  #spread the data
  dcast(., region ~ language, value.var = "primary_speakers", fun.aggregate = sum) %>%
  #join in the spatial geometry
  left_join(., south_africa) %>%
  #convert to sf
  st_as_sf()

If that does not fix your problem, please try to post a reproducible example. There are several posts and tutorials about how to do that. Here is one: FAQ: Reprex, How To

0 Likes