On my desktop, creating mydata does feel a little slow. It has 10mil values in it.
Have a look at the reprex below. (On making a good reproducible example, note that it's important to include any libraries you call upon. Also note I needed to hide the line referring to RX object since it was never set-up before it was called. =)
library(dplyr)
system.time({
mydata<-as.data.frame(replicate(100,rnorm(100000,0,1)))
})
#> user system elapsed
#> 0.779 0.101 0.886
system.time({
mydata$group=rpois(100000,5)
mydata$group.2=rpois(100000,500)
})
#> user system elapsed
#> 0.010 0.001 0.011
system.time({
test <- mydata %>%
group_by(group,group.2) %>%
summarise_at(vars(V1:V10),sum)%>%
ungroup
})
#> user system elapsed
#> 0.023 0.001 0.024
# RX <- RX %>%
# group_by(DUPERSID,EVNTIDX) %>%
# summarise_at(vars(RXXP[i]),sum) %>%
# ungroup
Created on 2019-04-16 by the reprex package (v0.2.1)
In terms of speeding up R,
John Mount explores some options here: