library(dplyr)
## Warning: package 'dplyr' was built under R version 3.5.3
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
df <- starwars
df$name
## [1] "Luke Skywalker" "C-3PO"
## [3] "R2-D2" "Darth Vader"
## [5] "Leia Organa" "Owen Lars"
## [7] "Beru Whitesun lars" "R5-D4"
## [9] "Biggs Darklighter" "Obi-Wan Kenobi"
## [11] "Anakin Skywalker" "Wilhuff Tarkin"
## [13] "Chewbacca" "Han Solo"
## [15] "Greedo" "Jabba Desilijic Tiure"
## [17] "Wedge Antilles" "Jek Tono Porkins"
## [19] "Yoda" "Palpatine"
## [21] "Boba Fett" "IG-88"
## [23] "Bossk" "Lando Calrissian"
## [25] "Lobot" "Ackbar"
## [27] "Mon Mothma" "Arvel Crynyd"
## [29] "Wicket Systri Warrick" "Nien Nunb"
## [31] "Qui-Gon Jinn" "Nute Gunray"
## [33] "Finis Valorum" "Jar Jar Binks"
## [35] "Roos Tarpals" "Rugor Nass"
## [37] "Ric Olié" "Watto"
## [39] "Sebulba" "Quarsh Panaka"
## [41] "Shmi Skywalker" "Darth Maul"
## [43] "Bib Fortuna" "Ayla Secura"
## [45] "Dud Bolt" "Gasgano"
## [47] "Ben Quadinaros" "Mace Windu"
## [49] "Ki-Adi-Mundi" "Kit Fisto"
## [51] "Eeth Koth" "Adi Gallia"
## [53] "Saesee Tiin" "Yarael Poof"
## [55] "Plo Koon" "Mas Amedda"
## [57] "Gregar Typho" "Cordé"
## [59] "Cliegg Lars" "Poggle the Lesser"
## [61] "Luminara Unduli" "Barriss Offee"
## [63] "Dormé" "Dooku"
## [65] "Bail Prestor Organa" "Jango Fett"
## [67] "Zam Wesell" "Dexter Jettster"
## [69] "Lama Su" "Taun We"
## [71] "Jocasta Nu" "Ratts Tyerell"
## [73] "R4-P17" "Wat Tambor"
## [75] "San Hill" "Shaak Ti"
## [77] "Grievous" "Tarfful"
## [79] "Raymus Antilles" "Sly Moore"
## [81] "Tion Medon" "Finn"
## [83] "Rey" "Poe Dameron"
## [85] "BB8" "Captain Phasma"
## [87] "Padmé Amidala"
library(dplyr)
df <- starwars
df$height
## [1] 172 167 96 202 150 178 165 97 183 182 188 180 228 180 173 175 170
## [18] 180 66 170 183 200 190 177 175 180 150 NA 88 160 193 191 170 196
## [35] 224 206 183 137 112 183 163 175 180 178 94 122 163 188 198 196 171
## [52] 184 188 264 188 196 185 157 183 183 170 166 165 193 191 183 168 198
## [69] 229 213 167 79 96 193 191 178 216 234 188 178 206 NA NA NA NA
## [86] NA 165
library(dplyr)
df <- starwars
df$gender
## [1] "male" NA NA "male"
## [5] "female" "male" "female" NA
## [9] "male" "male" "male" "male"
## [13] "male" "male" "male" "hermaphrodite"
## [17] "male" "male" "male" "male"
## [21] "male" "none" "male" "male"
## [25] "male" "male" "female" "male"
## [29] "male" "male" "male" "male"
## [33] "male" "male" "male" "male"
## [37] "male" "male" "male" "male"
## [41] "female" "male" "male" "female"
## [45] "male" "male" "male" "male"
## [49] "male" "male" "male" "female"
## [53] "male" "male" "male" "male"
## [57] "male" "female" "male" "male"
## [61] "female" "female" "female" "male"
## [65] "male" "male" "female" "male"
## [69] "male" "female" "female" "male"
## [73] "female" "male" "male" "female"
## [77] "male" "male" "male" "female"
## [81] "male" "male" "female" "male"
## [85] "none" "female" "female"
library(dplyr)
df <- starwars
df[1,]
## # A tibble: 1 x 13
## name height mass hair_color skin_color eye_color birth_year gender
## <chr> <int> <dbl> <chr> <chr> <chr> <dbl> <chr>
## 1 Luke~ 172 77 blond fair blue 19 male
## # ... with 5 more variables: homeworld <chr>, species <chr>, films <list>,
## # vehicles <list>, starships <list>
library(dplyr)
df <- starwars
df[ ,4]
## # A tibble: 87 x 1
## hair_color
## <chr>
## 1 blond
## 2 <NA>
## 3 <NA>
## 4 none
## 5 brown
## 6 brown, grey
## 7 brown
## 8 <NA>
## 9 black
## 10 auburn, white
## # ... with 77 more rows
library(dplyr)
df <- starwars
df[1:4]
## # A tibble: 87 x 4
## name height mass hair_color
## <chr> <int> <dbl> <chr>
## 1 Luke Skywalker 172 77 blond
## 2 C-3PO 167 75 <NA>
## 3 R2-D2 96 32 <NA>
## 4 Darth Vader 202 136 none
## 5 Leia Organa 150 49 brown
## 6 Owen Lars 178 120 brown, grey
## 7 Beru Whitesun lars 165 75 brown
## 8 R5-D4 97 32 <NA>
## 9 Biggs Darklighter 183 84 black
## 10 Obi-Wan Kenobi 182 77 auburn, white
## # ... with 77 more rows
library(dplyr)
df <- starwars
dim(df)
## [1] 87 13