r - 如何合并重复项
问题描述
我在数据集中有几个重复的条目。我想组合然后将结束列添加在一起。见下文。
我有的:
Main | FLOW22016| FLOW2| Forest Lakes| 2016| 2016-10-03| 0| Creek chub| Semotilus atromaculatus| 1|
Main | FLOW22016| FLOW2| Forest Lakes| 2016| 2016-10-03| 0| Creek chub| Semotilus atromaculatus| 1|
我想要的是
Main | FLOW22016| FLOW2| Forest Lakes| 2016| 2016-10-03| 0| Creek chub| Semotilus atromaculatus | 2|
这可能吗?我有很多这样的数据点,我想结合起来。
解决方案
尝试,
library(dplyr)
df %>%
group_by(across(c( - lastcolumn))) %>%
summarise(lastcolumn = n())
哪里lastcolumn
是 1 并且需要变为 2 的列。
推荐阅读
- scala - Gatling 如何创建列表并将其传递给会话?
- ffmpeg - 是否可以在 SDP 上调整 ffmpeg 的超时?
- python-3.x - 我怎样才能将所有这些听写合二为一?
- ios - SceneKit 着色器修改器未修改几何体的位置
- python - 从大型 dfs2 文件中提取 dfs0
- linux - 如何修复无法为虚拟机 kali-linux-2020.3-vbox-amd34 打开会话
- java - 错误 | 发生异常:org.apache.wicket.core.request.handler.ListenerInvocationNotAllowedException:行为拒绝接口调用
- cdn - 我无法导入 js 库脚本 p5.js CDN 错误
- google-chrome - NET::ERR_CERT_VALIDITY_TOO_LONG - 服务器证书的有效期过长
- sql - 优化 SQL 查询:如何检查一个 Id 是否分配给了比其他 Id 更多的 Id(不应该)