Given a vector goals <- c(2, 3, 1, 4,2,0,1,4,3,2) that represents the number of goals scored per game, answer the following questions.
#Compute the vector of goals
goals<-c(2, 3, 1, 4, 2, 0, 1, 4, 3, 2)
What is the total number of goals scored?
total_goals<-sum(goals)
cat("Total goals scored: ", total_goals, "\n")
## Total goals scored: 22
What is the average number of goals scored per game?
average_goals<-mean(goals)
cat("Average goals scored per game: ", average_goals, "\n")
## Average goals scored per game: 2.2
What is the maximum number number of goals scored in a single game?
max_goals<-max(goals)
cat("Maximum goals in a single game: ", max_goals, "\n")
## Maximum goals in a single game: 4
What is the minimum number of goals scored in a single game?
min_goals <-min(goals)
cat("Minimum goals in a single game: ", min_goals, "\n")
## Minimum goals in a single game: 0