Calculate weighted mean for two columns and hundreds of rows? I'm trying to teach myself basics of R and I couldn't find the answer:

Say, I have a csv file and I want to calculate weighted mean for each subject such that I have a mean mu = 0.015*1030+0.16*26930+0.24*0+0.87*250+0.29*310+0.77*6240+0.98*3730+0.98*0+0.08*1400 for Subject A, for example.

How would I accomplish it in R or Excel?

Also, if I need to multiply each pair by corresponding value from the same row from the column salary:

0.015*1030*111+0.16*26930*222+0.24*0*333+0.87*250*444+0.29*310*555+0.77*6240*666+0.98*3730*777+0.98*0*888+0.08*1400*999

Thanks



UPDATE:
Given your data is in DataFrame called df, you can simply do this: 

mu = sum(df$Probability * df$SubjectA * df$salary)