SyntaxFix
Write A Post
Hire A Developer
Questions
This should do your work :
df_agg <- aggregate(num~name+type,df,FUN=NROW) names(df_agg)[3] <- "count" df <- merge(df,df_agg,by=c('name','type'),all.x=TRUE)