在R中合并一对多数据以用于分类变量
我有2个数据集。一个与事故相关的,另一个与涉及的车辆有关。现在,1事故可能涉及多个车辆。合并这些时,我需要一排事故 - >因此,我正在尝试考虑采取同样的策略。对于车辆中的数值变量,我计划采用平均值(例如驾驶员,发动机电源等年龄),但是,如何将3-4行分类变量合并为1行?就像假设是否有两名男性和两名女性用于驾驶员的性别,这是我要选择的是基于频率的?
I have 2 datasets. One associated with Accidents and one with the vehicles involved in the same. Now 1 accident can have more than one vehicles involved. While merging these, I need a single row of accident -> vehicle and hence, I am trying to think of a strategy to do the same. For numerical variables in vehicles, I plan to take the average (like Age of driver, engine power, etc.), however, how exactly can I merge 3-4 rows of categorical variables into 1 row? Like let's say if there are two males and two females for sex of driver, which one to choose if I am looking at frequency-based?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这样的东西?
由
Something like this?
Created on 2022-06-10 by the reprex package (v2.0.0)