Hello,
I'm a bit confused trying to rearrange some factors.
This is the example:
set.seed(123)
fff=tibble(region=round(runif(20, min=1, max=4),0),
geta=runif(20, min=50, max=150))
fff=fff %>%
mutate(region=factor(region)) %>%
mutate(region=factor(region, 1:4 , c("a","b","c","d")))
fff
fff %>% group_by(region) %>% count()
# A tibble: 4 x 2
# Groups: region [4]
region n
<fct> <int>
1 a 3
2 b 6
3 c 5
4 d 6
But I want to reproduce this
This is the example:
...
fff %>% group_by(region) %>% count()
# A tibble: 4 x 2
# Groups: region [4]
region n
<fct> <int>
1 d 6
2 b 6
3 a 3
4 c 5
I run some code with fct_relevel o fct_reorder, but I can't achieve what I need.
Thanks for your time and interest.