Get startedGet started for free

Select elements

In the previous video, Filip explained how subsetting, using square brackets, extended from vectors to matrices. In general, the following line selects an element that's on row i and column j from a matrix m:

m[i,j]

Let's go intergalactic on subsetting now! You'll continue working on star_wars_matrix, which is still a matrix containing both US and non-US box office figures for the first three movies.

This exercise is part of the course

Introduction to R for Data Science (Microsoft)

View Course

Exercise instructions

  • Select the US box office figure for "The Empire Strikes Back".
  • Select the non-US box office number for "A New Hope" No need to assign these elements to new variables; simply print them.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# star_wars_matrix is already defined in your workspace

# US box office revenue for "The Empire Strikes Back"


# non-US box office revenue for "A New Hope"

Edit and Run Code