I use the data that I have here.
I summarize the data and then want to use this to build a histogram.
Here is my code:
heights<-read.csv("reading_anthesis.csv",as.is=T)
str(heights)
summarySE <- function(data=NULL, measurevar, groupvars=NULL, na.rm=FALSE,
conf.interval=.95, .drop=TRUE) {
require(plyr)
length2 <- function (x, na.rm=FALSE) {
if (na.rm) sum(!is.na(x))
else length(x)
}
datac <- ddply(data, groupvars, .drop=.drop,
.fun = function(xx, col) {
c(N = length2(xx[[col]], na.rm=na.rm),
mean = mean (xx[[col]], na.rm=na.rm),
sd = sd (xx[[col]], na.rm=na.rm)
)
},
measurevar
)
datac <- rename(datac, c("mean" = measurevar))
datac$se <- datac$sd / sqrt(datac$N)
ciMult <- qt(conf.interval/2 + .5, datac$N-1)
datac$ci <- datac$se * ciMult
return(datac)
}
summary<-summarySE(heights, measurevar="height", groupvars=c("genotype", "treatment"))
summary.2<-summary
summary.2$genotype<-factor(summary.2$genotype)
summary.2$treatment<-factor(summary.2$treatment)
pd <- position_dodge(.9)
ggplot(summary.2, aes(x=genotype, y=height, fill=genotype)) +
geom_bar(position=position_dodge(), stat=identity, colour ="black") +
geom_errorbar(aes(ymin=height-se, ymax=height+se), colour="black", width=.3, position=pd) +
ylab("Height (cm)") +
theme(axis.title = element_text(size=14,face="bold"),
axis.text = element_text(size=13),
strip.text.y = element_text(size=12))
I get an error message: Error in stat$parameters : object of type 'closure' is not subsettable
And I cannot find where I have a function / vector that I did not define, as the previous messages were implied.
Very grateful for any help.