title: “Compute the Weighted Mean”
output: html_document

Example 2 Computing the Weighted Mean

Enter the numeric grades in a column. Then, enter the weights in a column.

grade <- c(4,3,4,2,4)     # Letter grades as numeric values
weight <- c(4,3,3,5,1)    # Number of credit hours as the weights
weighted.mean(grade,weight)
## [1] 3.1875

If you want to round the value to the nearest hundredth (as is done with grade point averages), then use the round( ) command.

grade <- c(4,3,4,2,4)     # Letter grades as numeric values
weight <- c(4,3,3,5,1)/16    # Number of credit hours as the weights
round(weighted.mean(grade,weight),2)
## [1] 3.19