Hi Community
Im want make a bar plot but when try to order the x axis not work well. I need that the high values appear first (CCA, CDT, TSTF... etc). Im use fct_reorder
but no work well. Im try with dplyr
but not work.
library(tidyverse)
library(forcats)
d2 %>%
mutate(TITULO = fct_reorder(TITULO, VALOR)) %>%
ggplot(aes(x=reorder(TITULO,-VALOR) ,y=VALOR,
fill=TITULO)) +
geom_bar(stat="identity")+
ggtitle("TITULOS EMISOR - BBVA ") +
xlab("TÍTULO")+
theme(axis.text.x = element_text(angle = 90, vjust = 0.5,
hjust=1))
d2<-structure(list(TITULO = c("ABENVS", "ABENVS", "ABENVS", "ABENVS",
"ABENVS", "ABENVS", "ABENVS", "ABEVS", "ABEVS", "ABEVS", "ABEVS",
"ABEVS", "ABEVS", "ABEVS", "ABEVS", "ABEVS", "ANLB", "BGEVS",
"BGEVS", "BOENVS", "BOENVS", "BOENVS", "BOENVS", "BOENVS", "BOENVS",
"BOENVS", "BOENVS", "BOEOM", "BOEVS", "BOEVS", "BOEVS", "BOEVS",
"BOEVS", "BOEVS", "BOEVS", "BOEVS", "BOEVS", "BOEVS", "BPAZ",
"BPEN", "BPEN", "CCA", "CCA", "CCA", "CCA", "CCA", "CCA", "CCA",
"CCA", "CCA", "CCA", "CCA", "CCA", "CCA", "CCACP", "CCACP", "CCATP",
"CCATP", "CCATP", "CCATP", "CCC", "CCETP", "CDT", "CDT", "CDT",
"CDT", "CDT", "CDT", "CDT", "CDT", "CDT", "CDT", "CDT", "CDT",
"CDT", "CDT", "CDT", "CDT", "CDT", "CDT", "CDT", "CDT", "CDT",
"CDT", "CDT", "CDT", "CDT", "CDT", "CDT", "CDT", "CDT", "CDT",
"CDT", "CDT", "CDT", "CDT", "DPATAUT", "DPATAUT", "OTDP", "OTPENVS",
"OTPENVS", "OTPENVS", "OTPEVS", "PCCBCTP", "TCCEVS", "TCCH",
"TDERECON", "TDERECON", "TDERECON", "TDERECON", "TDERECON", "TDERECON",
"TDERECON", "TDERECON", "TDERECON", "TDERECON", "TDPE", "TDPIT",
"TDPIT", "TDPIT", "TIDIS", "TRD", "TSTF", "TSUV"), VALOR = c(0,
417.121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 15508.706, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10420.323, 0,
0, 247.521, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5086.858, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3134.988,
0, 0, 5587.902, 0, 0, 0, 0, 0, 0, 4732.015, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12603.703, 0)), row.names = c(NA,
-124L), class = c("tbl_df", "tbl", "data.frame"))
Thanks for guidence