I have been currently working on a solution to this but would like to see if there is already a solution to this that exists. I would like for items within the same group to have identical colours.
continent <- c("NA", "NA", "Europe", "Europe", "Europe:, "Asia", "Asia", "Asia") country <- c("USA", "Canada", "Germany", "France", "England", "China", "India", "Vietnam")
in this example, for example since USA and Canada are both in NA (North America), I would for example like for the USA to be darker blue and Canada to have a lighter blue. Similarly, since Germany, France and England are all in Europe, I would like Germany to for example be dark red, France to be a lighter red and England to have the lightest red colour. A similar logic can be applied for the Asian countries.
Is there a function in R that does this automatically for a (theoretically) high amount of different groups?