首页 > 解决方案 > How to extract data from a data table in R

问题描述

I am asking a pretty basic question: how to pull out "Female" data from this table and calculating average number for "Females" using R. Two columns 1. sex 2. height

sex    height
Male   75.00000
Male   70.00000
Female 65.00000
Female 66.00000

Thanks a lot!

标签: raggregate

解决方案


如果您使用的是 data.table,请使用此

dt[,avg:=mean(height),by=.(sex)]


推荐阅读