r - 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!
解决方案
如果您使用的是 data.table,请使用此
dt[,avg:=mean(height),by=.(sex)]
推荐阅读
- python - 使用经过训练的 GB 分类器处理新数据
- python - python从文件中提取文件时出错
- python - Numpy 的“shape”函数返回二维数组的一维值
- mysql - 我正在使用 IN 运算符,但仍然出现错误:“子查询返回超过 1 行”
- arrays - 无法使用 Pubsub 客户端将 Jsonbuffer[768] 发布到 mqtt。(控制器 esp32 Wroom 32)
- email - RFC822 的“Received:”标头定义中的“初始形式”是什么意思?
- flutter - 颤动中的DropdownButton中的多项选择
- vue.js - VUEJS - 加载后自动播放多个视频
- gitlab - 在 Gitlab CI 中按顺序运行同一阶段的作业
- autodesk-forge - 在有两个查看器的同时在两个 Forge Viewer 中轨道相同