Public-Health-Scotland / phsstyles

Standard Graphic Styles for use in Public Health Scotland (https://public-health-scotland.github.io/phsstyles/)
https://public-health-scotland.github.io/phsstyles/
Other
14 stars 1 forks source link

Error with `scale_colour_discrete_phs` #1

Closed Moohan closed 2 years ago

Moohan commented 2 years ago

Hey, I just tried using scale_colour_discrete_phs with a plot and got an error. I made up a reprex and got the same error:

library(tidyverse)
tibble(
  year = rep(c(2011:2020), 3),
  value = rnorm(30),
  group = as.factor(rep(1:3, 10))
) %>%
  ggplot(aes(x = year, y = value, colour = group)) +
  phsstyles::scale_colour_discrete_phs()
Error in name %in% phs_palette_types[["seq"]] : 
  object 'phs_palette_types' not found

Hopefully, that means something to you!

Tina815 commented 2 years ago

@Moohan Hi James, I've had a look and sorry for late reply. phs_palette_types is stored in the package so you have to first load the package using library(). Sorry that phsstyles:: won't work. I know sometimes it can be inconvenient for users but it's easy to maintain from a developer's perspective. Otherwise I have to include those objects in every function and if anything changes to those objects I have to update every function - this will make the package harder to maintain.

I have been developing a package called "phsverse". It combines all PHS developed packages. So in the future users should be able to only load "phsverse" and everything will be there. It should hopefully give users some convenience.

I hope this helps. If you think it's okay for now could you please close the issue? Thanks.

Moohan commented 2 years ago

Hi Tina, thanks for having a look. That is a bit annoying but totally makes sense.

I'm excited for phsverse!