Minha variável está com as seguintes informações:
H1
1 2 3 4 5 6 7 8 9
2.0383404 1.8159832 1.3828402 1.7176845 2.1172450 1.7641513 1.9149592 2.2764227 1.8691503
10 11 12 13 14 15 16 17 18
0.8159206 1.3759293 2.0422802 1.7177790 2.1467069 1.6821608 1.8776331 1.5601782 2.1066628
19 20 21 22 23 24 25 26 27
2.5448239 2.4000201 2.0851261 1.5697170 1.3886069 1.6747003 2.0600799 2.3156498 1.8779800
28 29 30 31 32 33 34 35 36
1.9996530 2.4976951 1.5419764 1.9834932 1.9713327 1.6065228 1.7298201 2.0126926 1.1275348
37 38 39 40 41 42 43 44 45
1.4611291 2.2055984 1.6963750 1.3337448 2.0414910 2.6911708 2.2434521 2.5294555 2.6935552
46 47 48
2.0341960 2.7750777 2.8078837
dput(H1)
structure(c(`1` = 2.0383404, `2` = 1.8159832, `3` = 1.3828402,
`4` = 1.7176845, `5` = 2.117245, `6` = 1.7641513, `7` = 1.9149592,
`8` = 2.2764227, `9` = 1.8691503, `10` = 0.8159206, `11` = 1.3759293,
`12` = 2.0422802, `13` = 1.717779, `14` = 2.1467069, `15` = 1.6821608,
`16` = 1.8776331, `17` = 1.5601782, `18` = 2.1066628, `19` = 2.5448239,
`20` = 2.4000201, `21` = 2.0851261, `22` = 1.569717, `23` = 1.3886069,
`24` = 1.6747003, `25` = 2.0600799, `26` = 2.3156498, `27` = 1.87798,
`28` = 1.999653, `29` = 2.4976951, `30` = 1.5419764, `31` = 1.9834932,
`32` = 1.9713327, `33` = 1.6065228, `34` = 1.7298201, `35` = 2.0126926,
`36` = 1.1275348, `37` = 1.4611291, `38` = 2.2055984, `39` = 1.696375,
`40` = 1.3337448, `41` = 2.041491, `42` = 2.6911708, `43` = 2.2434521,
`44` = 2.5294555, `45` = 2.6935552, `46` = 2.034196, `47` = 2.7750777,
`48` = 2.8078837), dim = 48L, dimnames = list(c("1", "2", "3",
"4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15",
"16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26",
"27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37",
"38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48"
)), class = "table")
E estou com esse código que gera um gráfico de barras:
grafico <- data.frame(X=names(H1), Y=H1)
ggplot(grafico, aes(y=Y, x=X)) +
geom_col(fill=gray(.3)) +
scale_y_continuous(limits=c(0, 3), breaks=seq(0, 3, .5)) +
geom_hline(yintercept=mean(grafico$Y),
color="red", size=2, linetype="dashed") +
theme_classic(base_size=16) +
xlab("Parcelas") +
ylab("Índice de diversidade de Shannon–Weaver (H)")
Porém, a ordem dos fatores no eixo x do gráfico não aparece em ordem crescente, como esperava que acontecesse.
Como resolver isso?