Hello, I have a data table like this one:
value treatment time Protein.A Protein.B
1 mean group1 24h 1.00 10.00
2 mean group2 24h 2.00 11.00
3 mean group3 24h 3.00 12.00
4 mean group4 24h 4.00 13.00
5 mean group5 24h 5.00 14.00
6 mean group1 48h 6.00 15.00
7 mean group2 48h 7.00 16.00
8 mean group3 48h 8.00 17.00
9 mean group4 48h 9.00 18.00
10 mean group5 48h 10.00 19.00
11 sd group1 24h 0.15 1.10
12 sd group2 24h 0.36 1.87
13 sd group3 24h 0.36 1.68
14 sd group4 24h 0.72 2.21
15 sd group5 24h 0.50 2.80
16 sd group1 48h 0.60 2.40
17 sd group2 48h 0.84 2.72
18 sd group3 48h 1.36 2.89
19 sd group4 48h 1.17 2.16
20 sd group5 48h 1.90 2.85
For each protein, I want to make a bar chart with the x = treatment grouped by time, y = mean value of Protein A. Then, the error bar will be added by the sd value of protein A as well. Is it possible to do it with ggplot2? Can I make a loop to plot the bar chart for each protein? I do have 50 proteins that need to plot. Thank you,
What have you tried? You seem to have the requirement mapped out very well, so translating it to ggplot2 aesthetics should be pretty straightforward. Start with
ggplot(dataset, aes(x=treatment, y=...))
, before which you way want totidyr::pivot_wider
somean
andsd
become their own columns.