在一列中的任何重复值处,我都希望它们在R中的组合计数

时间:2019-05-14 04:20:45

标签: r

我的数据框中有3列-类别,问题和计数。 所以无论哪里有重复的问题,我都想要那个问题及其合并计数 我的数据框中有很多重复的问题,这里我提供了其中一个。 例如:我从哪里获得固定物品是一个重复的问题-为此,我希望合并计数= 145 + 3 = 148作为该问题和类别旁边的另一个数据框中的答案

 a <- data.frame(Category =c("Stationary","Transfer","Stationary"), Question =c( "Where do I get stationary items from?","Process for claiming Transfer relocation allowances.","Where do I get stationary items from?"),Count = c(145,20,3),stringsAsFactors = FALSE)

预期结果:

    a1 <- data.frame(Category =c("Stationary","Transfer"),Question =c( "Where do I get stationary items from?","Process for claiming Transfer relocation allowances"),Count = c(148,20),stringsAsFactors = FALSE)

0 个答案:

没有答案