outAct的样本
Activity ReactionType numberActivities
activator activates 16
binding binds 83
recombinase binds 1
branching branches 3
carboxylase carboxylates 36
peptidase cleaves 425
endopeptidase cleaves 368
nuclease cleaves 53
glycosylase cleaves 24
cyclase converts 12
transhydrogenase converts 3
hist deacetylase deacetylates 8
deacetylase deacetylates 16
我想计算所有相同的ReactionTypes并总结它们的numberActivities
reaction_types <-aggregate(numberActivities ~ ReactionType, unique(outAct), FUN=sum)
期望的输出
ReactionType number
activates 16
binds 84
branches 3
carboxylates 36
cleaves 870
converts 15
deacetylates 24
问题是,我得到重复,即它们不算作一个唯一的反应类型,例如输出包含诸如
之类的行deacetylates 8
deacetylates 16
整个输出文件中有更多这样的例子。 我哪里错了?
提前致谢。
答案 0 :(得分:0)
library(dplyr)
outAct %>% group_by(ReactionType) %>% summarise(number = sum(numberActivities))