Hi everyone, I am new to R and need help adding error bars to my graphs.
my data set is:
Values Conc Media Toxin Genotype
|1|4878.833|250nM|Physio|DMSO|WT|
|2|4884.833|250nM|Physio|DMSO|KO|
|3|4854.167|250nM|OxPhos|DMSO|WT|
|4|4526.833|250nM|OxPhos|DMSO|KO|
|5|4943.500|250nM|Physio|Rotenone|WT|
|6|5108.167|250nM|Physio|Rotenone|KO|
|7|4404.833|250nM|OxPhos|Rotenone|WT|
|8|4970.833|250nM|OxPhos|Rotenone|KO|
|9|2558.167|500nM|Physio|DMSO|WT|
|10|2776.833|500nM|Physio|DMSO|KO|
|11|2906.500|500nM|OxPhos|DMSO|WT|
|12|2319.667|500nM|OxPhos|DMSO|KO|
|13|2446.167|500nM|Physio|Rotenone|WT|
|14|3772.667|500nM|Physio|Rotenone|KO|
|15|3505.667|500nM|OxPhos|Rotenone|WT|
|16|2749.167|500nM|OxPhos|Rotenone|KO|
What I used to create the graphs:
load packages
library(ggplot2)
library(ggpubr)
Import Data
Rename variable (sets "deadcell" to "df")
df <- deadcell
Set all categories to "factors"
df$Conc <- as.factor(df$Conc)
df$Media <- as.factor(df$Media)
df$Toxin <- as.factor(df$Toxin)
df$Genotype <- as.factor(df$Genotype)
Create a ggplot "object"
bp <- ggplot(df, aes(x = Conc, y = Values, group = Media, color = Genotype)) +
geom_point(aes(fill = Genotype, shape = Genotype), size = 2.5)
Creates the plot
bp + facet_wrap(Media~Toxin) +
theme(strip.text.x = element_text(face = "bold"),
axis.title.x = element_text(face = "bold"),
axis.title.y = element_text(face = "bold")) +
labs(x = "\nConcentration", y = "Values\n") + theme_bw()
What my graphs look like. I just need to add error bars. Any help I would appreciate.
