Consider the following vectors representing the number of three-pointers made and attempted by a basketball player in five games:
Three-Pointers Made: c(4, 5, 3, 6, 7)
Three-Pointers Attempted: c(9, 10, 8, 11, 12)
Calculate the three-point shooting percentage for each game and select the correct average three-point shooting percentage for the five games.
#Creating vector Three-Pointers Made
X3PM <- c(4, 5, 3, 6, 7)
X3PM
## [1] 4 5 3 6 7
#Creating vector Three-Pointers Attempted
X3PA <- c(9, 10, 8, 11, 12)
X3PA
## [1] 9 10 8 11 12
#obtaining the difference
X3PR <-(X3PM/X3PA)*100
X3PR
## [1] 44.44444 50.00000 37.50000 54.54545 58.33333
For game 1 the accuracy for the shooting percentage was 44.44%
For game 2 the accuracy for the shooting percentage was 50%
For game 3 the accuracy for the shooting percentage was 37.50%
For game 4 the accuracy for the shooting percentage was 54.54%
For game 5 the accuracy for the shooting percentage was 58.33%
#Example on getting the shooting percentage for game 2
X3PR[2]
## [1] 50
In game 2 the accuracy was 50%
# Calculate the average 3-points attempts percentage
Ave3PP <- mean(X3PR)
Ave3PP
## [1] 48.96465
There is an average of 48.96% that the team make 3 points attempt.