简体   繁体   中英

How to combine mean+sd into a table in R?

Right now I have the following code for mean and sd seperated as

aggregate(renters$rentm25,
          list(Province = renters$pvreg25, Mean = renters$pvreg25), mean)

aggregate(renters$rentm25,
          list(Province = renters$pvreg25, Mean = renters$pvreg25), sd)

Data

在此处输入图片说明

I also want to know how I can change the value of x to name it as mean and sd?

The doBy package doesn't get a lot of attention, but it does this job nicely:

library(doBy)
summaryBy(rentm25 ~ pvreg25, FUN=c(mean, sd), data=renters)

But since you did not provide example data, it is not clear that this is what you are looking for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM