I have a data frame like this:
Steps Item_number avg
1 Item 1 172
2 Item 1 817
3 Item 1 110
4 Item 1 703
5 Item 1 74
6 Item 1 12
7 Item 1 12
8 Item 1 87
1 Item 2 172
2 Item 2 817
3 Item 2 110
4 Item 2 703
5 Item 2 74
6 Item 2 12
7 Item 2 12
8 Item 2 87
1 Item 3 11
2 Item 3 817
3 Item 3 110
4 Item 3 703
5 Item 3 745
6 Item 3 92
7 Item 3 192
8 Item 3 831
And I would like a panel with the 3 different bar graph, one for each item. with x-axis representing the Steps
and y-axis the avg
value. Something like the image below (the bars are not matching the avg
values provided above)
I would love to learn how to do it using ggplot and geom_bar, if possible. Thanks!
Try something like this:
dataframe %>% ggplot()+
geom_bar(aes(x = Steps, y = avg, fill = Item_number), stat = "identity")+
facet_wrap(~Item_number, nrow = 3)+
theme_bw()
facet_wrap
plots one graph for each level (I think that's what you wanted)
If you need any further explanation, tell me!