Does anybody know how to aggregate by NA in R.
If you take the example below
a <- matrix(1,5,2) a[1:2,2] <- NA a[3:5,2] <- 2 aggregate(a[,1]
Use summarize from dplyr
library(dplyr) a %>% as.data.frame %>% group_by(V2) %>% summarize(V1_sum = sum(V1))