Skip to content

Instantly share code, notes, and snippets.

@thisisnic
Last active November 29, 2018 08:54
Show Gist options
  • Save thisisnic/d206213dcba4866caf0e2cf4c42004f0 to your computer and use it in GitHub Desktop.
Save thisisnic/d206213dcba4866caf0e2cf4c42004f0 to your computer and use it in GitHub Desktop.
Use tibble::glimpse() instead of str() to get a quick view of data frames that can handle list columns.

Code:

str(starwars)

Output:

# Lots of output up here
...
  ..$ : chr 
  ..$ : chr 
  ..$ : chr 
  ..$ : chr 
  ..$ : chr "Belbullab-22 starfighter"
  ..$ : chr 
  ..$ : chr 
  ..$ : chr 
  ..$ : chr 
  ..$ : chr 
  ..$ : chr 
  ..$ : chr "T-70 X-wing fighter"
  ..$ : chr 
  ..$ : chr 
  ..$ : chr  "H-type Nubian yacht" "Naboo star skiff" "Naboo fighter"

Code:

library(tibble)
glimpse(starwars)

Output:

Observations: 87
Variables: 13
$ name       <chr> "Luke Skywalker", "C-3PO", "R2-D2", "Darth Vader", "Leia Organa", "Owen Lars", "Beru Whitesun lars", "R5-D4", "Big...
$ height     <int> 172, 167, 96, 202, 150, 178, 165, 97, 183, 182, 188, 180, 228, 180, 173, 175, 170, 180, 66, 170, 183, 200, 190, 17...
$ mass       <dbl> 77.0, 75.0, 32.0, 136.0, 49.0, 120.0, 75.0, 32.0, 84.0, 77.0, 84.0, NA, 112.0, 80.0, 74.0, 1358.0, 77.0, 110.0, 17...
$ hair_color <chr> "blond", NA, NA, "none", "brown", "brown, grey", "brown", NA, "black", "auburn, white", "blond", "auburn, grey", "...
$ skin_color <chr> "fair", "gold", "white, blue", "white", "light", "light", "light", "white, red", "light", "fair", "fair", "fair", ...
$ eye_color  <chr> "blue", "yellow", "red", "yellow", "brown", "blue", "blue", "red", "brown", "blue-gray", "blue", "blue", "blue", "...
$ birth_year <dbl> 19.0, 112.0, 33.0, 41.9, 19.0, 52.0, 47.0, NA, 24.0, 57.0, 41.9, 64.0, 200.0, 29.0, 44.0, 600.0, 21.0, NA, 896.0, ...
$ gender     <chr> "male", NA, NA, "male", "female", "male", "female", NA, "male", "male", "male", "male", "male", "male", "male", "h...
$ homeworld  <chr> "Tatooine", "Tatooine", "Naboo", "Tatooine", "Alderaan", "Tatooine", "Tatooine", "Tatooine", "Tatooine", "Stewjon"...
$ species    <chr> "Human", "Droid", "Droid", "Human", "Human", "Human", "Human", "Droid", "Human", "Human", "Human", "Human", "Wooki...
$ films      <list> [<"Revenge of the Sith", "Return of the Jedi", "The Empire Strikes Back", "A New Hope", "The Force Awakens">, <"A...
$ vehicles   <list> [<"Snowspeeder", "Imperial Speeder Bike">, <>, <>, <>, "Imperial Speeder Bike", <>, <>, <>, <>, "Tribubble bongo"...
$ starships  <list> [<"X-wing", "Imperial shuttle">, <>, <>, "TIE Advanced x1", <>, <>, <>, <>, "X-wing", <"Jedi starfighter", "Trade...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment