1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to R

Connected

Exercise

Calculating the worldwide box office

The single most important thing for a movie in order to become an instant legend in Tinseltown is its worldwide box office figures.

To calculate the total box office revenue for the three Star Wars movies, you have to take the sum of the US revenue column and the non-US revenue column.

In R, the function rowSums() conveniently calculates the totals for each row of a matrix. This function creates a new vector:

rowSums(my_matrix)

Instructions

100 XP

Calculate the worldwide box office figures for the three movies and put these in the vector named worldwide_vector.