Trial: Binding

With this JedR Trial, you will prove your experience in combining data. While we are using the starwars data in a fashion, it has been broken up into parts that you need to put back together.


About our data

We start with three separate data frames for humans, droids and other species. The data frames have basic information on these characters, like height, weight, etc.

The droids data looks like this:

The humans and other data frames are similar, but have characters from those species only.

Stack the data

Starting with the droids data, stack it together with the two other data frames (humans and other) and store the result into a single data frame called characters. You should end up with 87 observations with 6 variables. After you create the characters data frame, print it out to your notebook.

Solution
characters <- droids |> bind_rows(humans, other) characters
characters <- droids |> 
  bind_rows(humans, other)

characters
Hint 1

You might review the bind vignette in the Tidyverse documentation.

Add columns with join

Now that you have created the characters data, we need to join this with a different data set. Our characters data has the name of the character along with variables for physical characteristics like height and weight, etc.

We have a different data set available to us, called sw_bio that has more information, like the homeworld and species of each character. It looks like this:

Your droid editor, J-327D, has asked you to add this sw_bio information to your characters data.

You should end up with the same 87 observations, but you should end up with 11 variables.

Solution
characters |> left_join(sw_bio)
characters  |> 
  left_join(sw_bio)
Hint

You might review the join vignette in the Tidyverse documentation.

You’re done with this Trial

You’ve got the strength of a thousand stormtroopers (but with way better aim)! Please inform your JedR Master that you have completed this trial. You are free to attempt the next JedR Trial or continue with JedR Training.