It looks like for every row, you could like to calculate the average number of sent items for the REP in the row. That actually can be better accomplished with the ave()
function.
Here's a sample data set
data <- data.frame(
Was.Sent=c("Sent","No")[c(1,1,2,1,2,1,2,1)],
REP=c(1,2,3,1,2,3,1,2)
)
And here's the code that will add a new column with the desired percent
data$psent<-with(data, ave(Was.Sent=="Sent", REP, FUN=mean))
And if I view the results, I see
cbind(data,psent)[order(data$REP, data$Was.Sent),]
# Was.Sent REP psent
#7 No 1 0.6666667
#1 Sent 1 0.6666667
#4 Sent 1 0.6666667
#5 No 2 0.6666667
#2 Sent 2 0.6666667
#8 Sent 2 0.6666667
#3 No 3 0.5000000
#6 Sent 3 0.5000000