I\'d like to plot continuous BMI on the y-axis and the categorical variable for Family Income on the x-axis and I\'d like the graph to plot the mean BMI for each category. Howev
This may work:
library(plyr) nhh<-ddply(nh,.(famIncome), summarise, mean.bmi=mean(bmi)) # find mean bmi with(nhh, plot(famIncome,mean.bmi)) # simple plot
Here's a base solution using aggregate:
aggregate
a <- aggregate(BMI ~ FamIncome, data=nh, FUN=mean) barplot(a$BMI, names.arg=a$FamIncome)