Mam problem z utworzeniem pogrupowanego wykresu słupkowego na ggplot. Nie wiem, jak ustawić oś y na grocie. Próbowałem już z funkcją stopu (), ale nie mogłem tego zrobić.
Oś x jest już ustawiona, teraz muszę ustawić zmienną "ab" jako oś y. Czy ktoś może mi pomóc?
Wielkie dzięki, bardzo doceniane!
dataset
ab estadio manejo
1 2506 Huevos mip
2 8616 Ninfas mip
3 229 Adultos mip
4 2183 Ninfas3-5 mip
5 134 Ninfaspar mip
6 1382 Huevos nomip
7 3481 Ninfas nomip
8 73 Adultos nomip
9 833 Ninfas3-5 nomip
10 na Ninfaspar nomip
> ggplot(mip,aes(x=estadio,fill=manejo, y=ab))+geom_bar(position="stack")+labs(title="MIP")
Error: stat_count() must not be used with a y aesthetic.
*2nd time
> df1<-melt(mip,id="ab")
Warning message:
attributes are not identical across measure variables; they will be dropped
> ggplot(df1,aes(estadio,ab,fill=manejo)) + geom_bar(position="stack") + labs(title="MIP")
Error in FUN(X[[i]], ...) : objeto "estadio" no encontrado
Odpowiedzi:
3 dla odpowiedzi № 1Nie musisz się topić, twoje dane są już w odpowiednim formacie.
ggplot(mip, aes(estadio, ab)) +
geom_col(aes(fill = manejo)) +
labs(title = "MIP")