I have a data frame that looks like this:
genotype DIV3 DIV4 ...
WT 12.4 15.2
WT 35.4 35.3
HET 1.3 1.2
HET 1.5 5.2
I calculate the means and sd by the following functions:
means = aggregate(. ~ genotype, data=dat, FUN=mean)
errors = aggregate(. ~ genotype, data=dat, FUN=sd)
I am using ggplot2 to plot the means as a scatter plot. I want to use the errors dataframe for error bars, but I am having trouble calculating ymin and ymax since I have two dataframes.
Is there a better way to do this?
EDIT: ggplot2 code:
x = melt(means)
ggplot(x_melt, aes(group=genotype, variable, value, col=genotype, shape = genotype)) +
geom_line() +
geom_point(size=3)+
theme(axis.text=element_text(size=14),
axis.title.x=element_blank(),
axis.text.x=element_text(angle = 45, vjust = 0.8, hjust = .9, color = "black"),
axis.text.y=element_text(color="black"))
mean
andsd
in a single datasetdo.call(
data.frame,aggregate(. ~genotype, dat, FUN= function(x) c(Mean=mean(x), SD=sd(x))))
– akrun