I want to change (place) in the list to 1 Europe, 2 Asia, 3 Africa, 4 Latin America, and 5 North America. so I can have names on the plot rather than numbers.
What I have so far:
I want to change (place) in the list to 1 Europe, 2 Asia, 3 Africa, 4 Latin America, and 5 North America. so I can have names on the plot rather than numbers.
What I have so far:
I think I didn't understand your question correctly at first. If you want to replace the values in a column with character strings and then use them in alphabetic order in ggplot you could try for example:
library(tidyverse)
last %>%
mutate(place = forcats::fct_recode(place %>% as.character(),
'Europe' = '1',
'Asia' = '2',
'Africa' = '3',
'Latin America' = '4',
'North America' = '5') %>% as.character())
And then use the place in facet_grid. It should wrap them in alphabetic order. See this reproducable version of it:
library(tidyverse)
mtcars %>%
mutate(am = forcats::fct_recode(am %>% as.character(),
'Africa' = '1',
'Europe' = '0') %>% as.character()) %>%
ggplot(aes(cyl, mpg)) +
geom_point() +
facet_grid(~am)
Does this work as you intented?