【发布时间】:2021-07-26 15:31:40
【问题描述】:
我有以下示例数据:
# data
school = c('ABC University','ABC Uni','DFG University','DFG U')
applicant = c(2000,3100,210,2000)
students = c(100,2000,300,4000)
df = data.frame(school,applicant,students)
我想合并到这个:
|school |appliant| students |
-----------------------------------
|ABC University| 5100 | 2100 |
|DFG University| 2210 | 4300 |
我运行了这段代码:
df$school[df$school == 'ABC Uni'] = 'ABC University'
但它给了我两次 ABC 大学,而不是将它们合并在一起。
【问题讨论】: