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



I'm trying to map the census data and plotting different ethnic groups:
I'm partially following this tutorial (
but when I'm trying to calculate the dot positions for each column I get this error:
Error in calc_dots(df =, 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(, Arab:Asian )/1000

Any help will be much appreciated,
Thank you



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

1 Like


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"



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(! %>%
  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

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