How to find the mean of a continuous variable for each categorical variable

后端 未结 2 937
孤独总比滥情好
孤独总比滥情好 2021-01-27 08:21

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

2条回答
  •  长情又很酷
    2021-01-27 08:46

    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
    

提交回复
热议问题