I have a data in table like this I need a barplot for the same in R.. So what I want is in the x-axis the High_score, Medium_score and Low_score should be plotted with the mean,max and standard deviation(means besides=TRUE )with three different color and the mean, max and SD should be represented in the legend. Can anyone please help me on this?
Asked
Active
Viewed 62 times
-3
-
1Welcome to SO. Please review [how to ask](https://stackoverflow.com/help/how-to-ask) questions, and then provide a [minimal reproducible example/attempt](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example), including sample data. A [screenshot of your data/code](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-on-so-when-asking-a-question/285557) is not useful. – Maurits Evers May 31 '18 at 04:38
1 Answers
1
library(tidyverse)
df <- data_frame(
"stat" = c("mean", "max", "sd"),
"High_score" = c(55.6, 60, 5.1),
"Medium_score" = c(40, 45, 4.3),
"Low_score" = c(20, 28, 3.8)
)
df <- gather(df, key = score, value = value, -stat)
ggplot(df, aes(x = score, y = value, fill = stat)) +
geom_col(position = "dodge")

Phil
- 7,287
- 3
- 36
- 66