【发布时间】:2020-10-15 15:57:05
【问题描述】:
我需要一次聚合不同类的多个变量。
test<- data.frame (name = c("anna", "joe", "anna"),
party = c("red", "blue", "red"),
text = c("hey there", "we ate an apple", "i took a walk"),
numberofwords = c(2, 4, 4),
score1 = 1:3,
score2 = 4:6)
现在是这个样子
# name party text numberofwords score1 score2
#1 anna red hey there 2 1 4
#2 joe blue we ate an apple 4 2 5
#3 anna red i took a walk 4 3 6
我想根据姓名和派对聚合 score1、score2、numberofwords、文本变量。
想要的结果是:
# name party text numberofwords score1 score2
#1 anna red hey there i took a walk 6 4 10
#2 joe blue we ate an apple 4 2 5
【问题讨论】:
标签: r dataframe dplyr tidyverse