Hi, I'm really new to using statistics and R and I need help with how to visualize my ANOVA results in a bar graph with error bars. I'm trying to follow this tutorial but I keep getting the error message: Error: 'names' attribute [20] must be the same length as the vector [1]
Here is my code:
data$group <- "NA" # make an empty column for the groups
data$group[1:4]<-"volant"
data$group[6:16]<-"terrestrial"
data$group[17:19]<-"semi-aquatic"
data$group[20] <- "aquatic"
cbind(data)
Group<-as.factor(data$group)
Species<-rownames(data)
x <- (data$functional_nonfunctional~data$habitat)
x<-data$functional_nonfunctional
Group<-data$habitat
names(x)<-rownames(data)
names(Group)<-rownames(data)
modelPHYLO<-aov.phylo(x~Group,tree)
summary(modelPHYLO)
var(data$functional_nonfunctional)
length(Group)
graph_summary <- ddply(data,Group, summarize, AVERAGE=mean(data$functional_nonfunctional), SE=sqrt(var(data$functional_nonfunctional)/length(functional_nonfunctional)))
I would SO appreciate any help! I'm feeling really stuck! Thank you
It would help if you added a little of what your data looked like, even just the first few lines of your data.frame. Use:
Also there are some inconsistencies in your code such as row 5 is not given a group (e.g. is it volant, terrestrial or other?) also you reassign the name Group and x to different objects which is confusing.
Oh wow I didn't even notice the row 5 thing thank you! The way that x is assigned to different things is confusing and doesn't make sense. The first x (
x <- (data$functional_nonfunctional~data$habitat)
) shouldn't be there now that I'm looking at it again.Here is part of my table: