Only planets with rings (2)
You probably remember from high school that some planets in our solar system have rings and others do not. Unfortunately you can not recall their names. Could R help you out?
If you type rings_vector
in the console, you get:
[1] FALSE FALSE FALSE FALSE TRUE TRUE TRUE TRUE
This means that the first four observations (or planets) do not have a ring (FALSE
), but the other four do (TRUE
). However, you do not get a nice overview of the names of these planets, their diameter, etc. Let's try to use rings_vector
to select the data for the four planets with rings.
This exercise is part of the course
Introduction to R
Exercise instructions
The code in the editor selects the name
column of all planets that have rings. Adapt the code so that instead of only the name
column, all columns for planets that have rings are selected.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# planets_df and rings_vector are pre-loaded in your workspace
# Adapt the code to select all columns for planets with rings
planets_df[rings_vector, "name"]