问题描述
a <- c(1,1,2,2)
b <- c(10,20,30,40,50,60)
y <- c(2000,2000,2001,2002,2002)
c <- cbind(b,a,y)
colnames(c) <- c("b","a","y")
我要做的就是将sum
函数应用于一组a
和y
。与输入相比,输出可能具有不同的dim
。
我希望得到以下结果:
aa <- c(1,2)
yy <- c(2000,2002)
bb <- c(30,110)
result <- cbind(bb,aa,yy)
我尝试了以下操作,但收效甚微:
as_tibble(c) %>% group_by(a,y) %>% mutate(tapply(,FUN = sum(b)))
解决方法
我认为您需要以下条件:
(lldb) help continue
Continue execution of all threads in the current process.
Syntax: continue <cmd-options>
Command Options Usage:
continue [-i <unsigned-integer>]
-i <unsigned-integer> ( --ignore-count <unsigned-integer> )
Ignore <N> crossings of the breakpoint (if it exists) for the currently selected thread.
'continue' is an abbreviation for 'process continue'
您可以使用基数R获得相同的结果:
break modify -i 10 <BKPTNO>
使用data.table
library(data.table)
as.data.table(c)[,lapply(.SD,sum),.(y,a)]