Estimation and uncertainty. The foundations of statistics

Review basic descriptive statistics

Load the data

pokemon <- read.csv("//isad.isadroot.ex.ac.uk/UOE/User/Desktop/Pokemon.csv", header = TRUE)

Data source: https://www.kaggle.com/abcsds/pokemon

Explore the data

names(pokemon)
##  [1] "X."         "Name"       "Type.1"     "Type.2"     "Total"     
##  [6] "HP"         "Attack"     "Defense"    "Sp..Atk"    "Sp..Def"   
## [11] "Speed"      "Generation" "Legendary"
summary(pokemon)
##        X.                             Name         Type.1   
##  Min.   :  1.0   Abomasnow              :  1   Water  :112  
##  1st Qu.:184.8   AbomasnowMega Abomasnow:  1   Normal : 98  
##  Median :364.5   Abra                   :  1   Grass  : 70  
##  Mean   :362.8   Absol                  :  1   Bug    : 69  
##  3rd Qu.:539.2   AbsolMega Absol        :  1   Psychic: 57  
##  Max.   :721.0   Accelgor               :  1   Fire   : 52  
##                  (Other)                :794   (Other):342  
##       Type.2        Total             HP             Attack   
##          :386   Min.   :180.0   Min.   :  1.00   Min.   :  5  
##  Flying  : 97   1st Qu.:330.0   1st Qu.: 50.00   1st Qu.: 55  
##  Ground  : 35   Median :450.0   Median : 65.00   Median : 75  
##  Poison  : 34   Mean   :435.1   Mean   : 69.26   Mean   : 79  
##  Psychic : 33   3rd Qu.:515.0   3rd Qu.: 80.00   3rd Qu.:100  
##  Fighting: 26   Max.   :780.0   Max.   :255.00   Max.   :190  
##  (Other) :189                                                 
##     Defense          Sp..Atk          Sp..Def          Speed       
##  Min.   :  5.00   Min.   : 10.00   Min.   : 20.0   Min.   :  5.00  
##  1st Qu.: 50.00   1st Qu.: 49.75   1st Qu.: 50.0   1st Qu.: 45.00  
##  Median : 70.00   Median : 65.00   Median : 70.0   Median : 65.00  
##  Mean   : 73.84   Mean   : 72.82   Mean   : 71.9   Mean   : 68.28  
##  3rd Qu.: 90.00   3rd Qu.: 95.00   3rd Qu.: 90.0   3rd Qu.: 90.00  
##  Max.   :230.00   Max.   :194.00   Max.   :230.0   Max.   :180.00  
##                                                                    
##    Generation    Legendary  
##  Min.   :1.000   False:735  
##  1st Qu.:2.000   True : 65  
##  Median :3.000              
##  Mean   :3.324              
##  3rd Qu.:5.000              
##  Max.   :6.000              
## 

Bonus, the ‘pshych’ package - describe() function

#install.packages("psych")
library("psych")
describe(pokemon)
##            vars   n   mean     sd median trimmed    mad min max range
## X.            1 800 362.81 208.34  364.5  362.99 263.16   1 721   720
## Name*         2 800 400.50 231.08  400.5  400.50 296.52   1 800   799
## Type.1*       3 800  10.47   5.58   11.0   10.69   7.41   1  18    17
## Type.2*       4 800   6.07   5.84    3.0    5.30   2.97   1  19    18
## Total         5 800 435.10 119.96  450.0  432.58 126.02 180 780   600
## HP            6 800  69.26  25.53   65.0   67.35  22.24   1 255   254
## Attack        7 800  79.00  32.46   75.0   77.16  29.65   5 190   185
## Defense       8 800  73.84  31.18   70.0   71.04  29.65   5 230   225
## Sp..Atk       9 800  72.82  32.72   65.0   70.16  29.65  10 194   184
## Sp..Def      10 800  71.90  27.83   70.0   69.98  29.65  20 230   210
## Speed        11 800  68.28  29.06   65.0   67.25  31.13   5 180   175
## Generation   12 800   3.32   1.66    3.0    3.28   2.97   1   6     5
## Legendary*   13 800   1.08   0.27    1.0    1.00   0.00   1   2     1
##             skew kurtosis   se
## X.          0.00    -1.17 7.37
## Name*       0.00    -1.20 8.17
## Type.1*    -0.28    -1.19 0.20
## Type.2*     0.70    -0.90 0.21
## Total       0.15    -0.52 4.24
## HP          1.56     7.15 0.90
## Attack      0.55     0.15 1.15
## Defense     1.15     2.69 1.10
## Sp..Atk     0.74     0.28 1.16
## Sp..Def     0.85     1.60 0.98
## Speed       0.36    -0.25 1.03
## Generation  0.01    -1.24 0.06
## Legendary*  3.06     7.37 0.01

Measures of central tendency

Refresher: page 60 Imai’s book

Mean

mean(pokemon$Speed)
## [1] 68.2775

Median

median(pokemon$Speed)
## [1] 65

Mode

#install.packages("modeest")
library(modeest)
## Warning: package 'modeest' was built under R version 3.3.3
## 
## This is package 'modeest' written by P. PONCET.
## For a complete list of functions, use 'library(help = "modeest")' or 'help.start()'.
mlv(pokemon$Speed, method = "mfv")
## Mode (most frequent value): 50 
## Bickel's modal skewness: 0.4 
## Call: mlv.integer(x = pokemon$Speed, method = "mfv")

Measures of spread

Refresher: page 63 Imai’s book

Variance

range(pokemon$HP)
## [1]   1 255
var(pokemon$HP)
## [1] 652.0193

Standard deviation

sd(pokemon$HP)
## [1] 25.53467

Standard deviation is the square root of variance. Let’s double check

sqrt(var(pokemon$HP))
## [1] 25.53467

Bonus: click here for a cute example

Frequency distribution

table()

table(pokemon$Type.1)
## 
##      Bug     Dark   Dragon Electric    Fairy Fighting     Fire   Flying 
##       69       31       32       44       17       27       52        4 
##    Ghost    Grass   Ground      Ice   Normal   Poison  Psychic     Rock 
##       32       70       32       24       98       28       57       44 
##    Steel    Water 
##       27      112
table(pokemon$Type.2)
## 
##               Bug     Dark   Dragon Electric    Fairy Fighting     Fire 
##      386        3       20       18        6       23       26       12 
##   Flying    Ghost    Grass   Ground      Ice   Normal   Poison  Psychic 
##       97       14       25       35       14        4       34       33 
##     Rock    Steel    Water 
##       14       22       14
table(pokemon$Generation)
## 
##   1   2   3   4   5   6 
## 166 106 160 121 165  82
table(pokemon$Legendary)
## 
## False  True 
##   735    65

hist() - ONLY FOR NUMERIC VARIABLES

hist(pokemon$Speed)

hist(pokemon$HP)

Type of variables

Quantitative

Interval scale

class(pokemon$Generation)
## [1] "integer"
table(pokemon$Generation)
## 
##   1   2   3   4   5   6 
## 166 106 160 121 165  82

Ratio scale

We don’t have one in this dataset ```

Qualitative

Ordinal

class(pokemon$Generation)
## [1] "integer"
table(pokemon$Generation)
## 
##   1   2   3   4   5   6 
## 166 106 160 121 165  82

Categorical

class(pokemon$Type.1)
## [1] "factor"
table(pokemon$Type.1)
## 
##      Bug     Dark   Dragon Electric    Fairy Fighting     Fire   Flying 
##       69       31       32       44       17       27       52        4 
##    Ghost    Grass   Ground      Ice   Normal   Poison  Psychic     Rock 
##       32       70       32       24       98       28       57       44 
##    Steel    Water 
##       27      112

Binary

class(pokemon$Legendary)
## [1] "factor"
table(pokemon$Legendary)
## 
## False  True 
##   735    65

The type of variables becomes extremely important when we are running analysis (we’ll learn later about that). For now. try to produce a histogram for the “Name” variable

# hist(pokemon$Name)
hist(pokemon$Generation)

Factor variables. They have levels

class(pokemon$Legendary)
## [1] "factor"
levels(pokemon$Legendary)
## [1] "False" "True"

Factor variables can be both categorical or binary. EVEN numeric. Remember, both numeric and character variables can be made into factors, but a factor’s levels will always be character values.

sapply(pokemon, class)
##         X.       Name     Type.1     Type.2      Total         HP 
##  "integer"   "factor"   "factor"   "factor"  "integer"  "integer" 
##     Attack    Defense    Sp..Atk    Sp..Def      Speed Generation 
##  "integer"  "integer"  "integer"  "integer"  "integer"  "integer" 
##  Legendary 
##   "factor"
levels(pokemon$Name)
##   [1] "Abomasnow"                 "AbomasnowMega Abomasnow"  
##   [3] "Abra"                      "Absol"                    
##   [5] "AbsolMega Absol"           "Accelgor"                 
##   [7] "AegislashBlade Forme"      "AegislashShield Forme"    
##   [9] "Aerodactyl"                "AerodactylMega Aerodactyl"
##  [11] "Aggron"                    "AggronMega Aggron"        
##  [13] "Aipom"                     "Alakazam"                 
##  [15] "AlakazamMega Alakazam"     "Alomomola"                
##  [17] "Altaria"                   "AltariaMega Altaria"      
##  [19] "Amaura"                    "Ambipom"                  
##  [21] "Amoonguss"                 "Ampharos"                 
##  [23] "AmpharosMega Ampharos"     "Anorith"                  
##  [25] "Arbok"                     "Arcanine"                 
##  [27] "Arceus"                    "Archen"                   
##  [29] "Archeops"                  "Ariados"                  
##  [31] "Armaldo"                   "Aromatisse"               
##  [33] "Aron"                      "Articuno"                 
##  [35] "Audino"                    "AudinoMega Audino"        
##  [37] "Aurorus"                   "Avalugg"                  
##  [39] "Axew"                      "Azelf"                    
##  [41] "Azumarill"                 "Azurill"                  
##  [43] "Bagon"                     "Baltoy"                   
##  [45] "Banette"                   "BanetteMega Banette"      
##  [47] "Barbaracle"                "Barboach"                 
##  [49] "Basculin"                  "Bastiodon"                
##  [51] "Bayleef"                   "Beartic"                  
##  [53] "Beautifly"                 "Beedrill"                 
##  [55] "BeedrillMega Beedrill"     "Beheeyem"                 
##  [57] "Beldum"                    "Bellossom"                
##  [59] "Bellsprout"                "Bergmite"                 
##  [61] "Bibarel"                   "Bidoof"                   
##  [63] "Binacle"                   "Bisharp"                  
##  [65] "Blastoise"                 "BlastoiseMega Blastoise"  
##  [67] "Blaziken"                  "BlazikenMega Blaziken"    
##  [69] "Blissey"                   "Blitzle"                  
##  [71] "Boldore"                   "Bonsly"                   
##  [73] "Bouffalant"                "Braixen"                  
##  [75] "Braviary"                  "Breloom"                  
##  [77] "Bronzong"                  "Bronzor"                  
##  [79] "Budew"                     "Buizel"                   
##  [81] "Bulbasaur"                 "Buneary"                  
##  [83] "Bunnelby"                  "Burmy"                    
##  [85] "Butterfree"                "Cacnea"                   
##  [87] "Cacturne"                  "Camerupt"                 
##  [89] "CameruptMega Camerupt"     "Carbink"                  
##  [91] "Carnivine"                 "Carracosta"               
##  [93] "Carvanha"                  "Cascoon"                  
##  [95] "Castform"                  "Caterpie"                 
##  [97] "Celebi"                    "Chandelure"               
##  [99] "Chansey"                   "Charizard"                
## [101] "CharizardMega Charizard X" "CharizardMega Charizard Y"
## [103] "Charmander"                "Charmeleon"               
## [105] "Chatot"                    "Cherrim"                  
## [107] "Cherubi"                   "Chesnaught"               
## [109] "Chespin"                   "Chikorita"                
## [111] "Chimchar"                  "Chimecho"                 
## [113] "Chinchou"                  "Chingling"                
## [115] "Cinccino"                  "Clamperl"                 
## [117] "Clauncher"                 "Clawitzer"                
## [119] "Claydol"                   "Clefable"                 
## [121] "Clefairy"                  "Cleffa"                   
## [123] "Cloyster"                  "Cobalion"                 
## [125] "Cofagrigus"                "Combee"                   
## [127] "Combusken"                 "Conkeldurr"               
## [129] "Corphish"                  "Corsola"                  
## [131] "Cottonee"                  "Cradily"                  
## [133] "Cranidos"                  "Crawdaunt"                
## [135] "Cresselia"                 "Croagunk"                 
## [137] "Crobat"                    "Croconaw"                 
## [139] "Crustle"                   "Cryogonal"                
## [141] "Cubchoo"                   "Cubone"                   
## [143] "Cyndaquil"                 "Darkrai"                  
## [145] "DarmanitanStandard Mode"   "DarmanitanZen Mode"       
## [147] "Darumaka"                  "Dedenne"                  
## [149] "Deerling"                  "Deino"                    
## [151] "Delcatty"                  "Delibird"                 
## [153] "Delphox"                   "DeoxysAttack Forme"       
## [155] "DeoxysDefense Forme"       "DeoxysNormal Forme"       
## [157] "DeoxysSpeed Forme"         "Dewgong"                  
## [159] "Dewott"                    "Dialga"                   
## [161] "Diancie"                   "DiancieMega Diancie"      
## [163] "Diggersby"                 "Diglett"                  
## [165] "Ditto"                     "Dodrio"                   
## [167] "Doduo"                     "Donphan"                  
## [169] "Doublade"                  "Dragalge"                 
## [171] "Dragonair"                 "Dragonite"                
## [173] "Drapion"                   "Dratini"                  
## [175] "Drifblim"                  "Drifloon"                 
## [177] "Drilbur"                   "Drowzee"                  
## [179] "Druddigon"                 "Ducklett"                 
## [181] "Dugtrio"                   "Dunsparce"                
## [183] "Duosion"                   "Durant"                   
## [185] "Dusclops"                  "Dusknoir"                 
## [187] "Duskull"                   "Dustox"                   
## [189] "Dwebble"                   "Eelektrik"                
## [191] "Eelektross"                "Eevee"                    
## [193] "Ekans"                     "Electabuzz"               
## [195] "Electivire"                "Electrike"                
## [197] "Electrode"                 "Elekid"                   
## [199] "Elgyem"                    "Emboar"                   
## [201] "Emolga"                    "Empoleon"                 
## [203] "Entei"                     "Escavalier"               
## [205] "Espeon"                    "Espurr"                   
## [207] "Excadrill"                 "Exeggcute"                
## [209] "Exeggutor"                 "Exploud"                  
## [211] "Farfetch'd"                "Fearow"                   
## [213] "Feebas"                    "Fennekin"                 
## [215] "Feraligatr"                "Ferroseed"                
## [217] "Ferrothorn"                "Finneon"                  
## [219] "Flaaffy"                   "Flabébé"                
## [221] "Flareon"                   "Fletchinder"              
## [223] "Fletchling"                "Floatzel"                 
## [225] "Floette"                   "Florges"                  
## [227] "Flygon"                    "Foongus"                  
## [229] "Forretress"                "Fraxure"                  
## [231] "Frillish"                  "Froakie"                  
## [233] "Frogadier"                 "Froslass"                 
## [235] "Furfrou"                   "Furret"                   
## [237] "Gabite"                    "Gallade"                  
## [239] "GalladeMega Gallade"       "Galvantula"               
## [241] "Garbodor"                  "Garchomp"                 
## [243] "GarchompMega Garchomp"     "Gardevoir"                
## [245] "GardevoirMega Gardevoir"   "Gastly"                   
## [247] "Gastrodon"                 "Genesect"                 
## [249] "Gengar"                    "GengarMega Gengar"        
## [251] "Geodude"                   "Gible"                    
## [253] "Gigalith"                  "Girafarig"                
## [255] "GiratinaAltered Forme"     "GiratinaOrigin Forme"     
## [257] "Glaceon"                   "Glalie"                   
## [259] "GlalieMega Glalie"         "Glameow"                  
## [261] "Gligar"                    "Gliscor"                  
## [263] "Gloom"                     "Gogoat"                   
## [265] "Golbat"                    "Goldeen"                  
## [267] "Golduck"                   "Golem"                    
## [269] "Golett"                    "Golurk"                   
## [271] "Goodra"                    "Goomy"                    
## [273] "Gorebyss"                  "Gothita"                  
## [275] "Gothitelle"                "Gothorita"                
## [277] "GourgeistAverage Size"     "GourgeistLarge Size"      
## [279] "GourgeistSmall Size"       "GourgeistSuper Size"      
## [281] "Granbull"                  "Graveler"                 
## [283] "Greninja"                  "Grimer"                   
## [285] "Grotle"                    "Groudon"                  
## [287] "GroudonPrimal Groudon"     "Grovyle"                  
## [289] "Growlithe"                 "Grumpig"                  
## [291] "Gulpin"                    "Gurdurr"                  
## [293] "Gyarados"                  "GyaradosMega Gyarados"    
## [295] "Happiny"                   "Hariyama"                 
## [297] "Haunter"                   "Hawlucha"                 
## [299] "Haxorus"                   "Heatmor"                  
## [301] "Heatran"                   "Heliolisk"                
## [303] "Helioptile"                "Heracross"                
## [305] "HeracrossMega Heracross"   "Herdier"                  
## [307] "Hippopotas"                "Hippowdon"                
## [309] "Hitmonchan"                "Hitmonlee"                
## [311] "Hitmontop"                 "Ho-oh"                    
## [313] "Honchkrow"                 "Honedge"                  
## [315] "HoopaHoopa Confined"       "HoopaHoopa Unbound"       
## [317] "Hoothoot"                  "Hoppip"                   
## [319] "Horsea"                    "Houndoom"                 
## [321] "HoundoomMega Houndoom"     "Houndour"                 
## [323] "Huntail"                   "Hydreigon"                
## [325] "Hypno"                     "Igglybuff"                
## [327] "Illumise"                  "Infernape"                
## [329] "Inkay"                     "Ivysaur"                  
## [331] "Jellicent"                 "Jigglypuff"               
## [333] "Jirachi"                   "Jolteon"                  
## [335] "Joltik"                    "Jumpluff"                 
## [337] "Jynx"                      "Kabuto"                   
## [339] "Kabutops"                  "Kadabra"                  
## [341] "Kakuna"                    "Kangaskhan"               
## [343] "KangaskhanMega Kangaskhan" "Karrablast"               
## [345] "Kecleon"                   "KeldeoOrdinary Forme"     
## [347] "KeldeoResolute Forme"      "Kingdra"                  
## [349] "Kingler"                   "Kirlia"                   
## [351] "Klang"                     "Klefki"                   
## [353] "Klink"                     "Klinklang"                
## [355] "Koffing"                   "Krabby"                   
## [357] "Kricketot"                 "Kricketune"               
## [359] "Krokorok"                  "Krookodile"               
## [361] "Kyogre"                    "KyogrePrimal Kyogre"      
## [363] "Kyurem"                    "KyuremBlack Kyurem"       
## [365] "KyuremWhite Kyurem"        "Lairon"                   
## [367] "Lampent"                   "LandorusIncarnate Forme"  
## [369] "LandorusTherian Forme"     "Lanturn"                  
## [371] "Lapras"                    "Larvesta"                 
## [373] "Larvitar"                  "Latias"                   
## [375] "LatiasMega Latias"         "Latios"                   
## [377] "LatiosMega Latios"         "Leafeon"                  
## [379] "Leavanny"                  "Ledian"                   
## [381] "Ledyba"                    "Lickilicky"               
## [383] "Lickitung"                 "Liepard"                  
## [385] "Lileep"                    "Lilligant"                
## [387] "Lillipup"                  "Linoone"                  
## [389] "Litleo"                    "Litwick"                  
## [391] "Lombre"                    "Lopunny"                  
## [393] "LopunnyMega Lopunny"       "Lotad"                    
## [395] "Loudred"                   "Lucario"                  
## [397] "LucarioMega Lucario"       "Ludicolo"                 
## [399] "Lugia"                     "Lumineon"                 
## [401] "Lunatone"                  "Luvdisc"                  
## [403] "Luxio"                     "Luxray"                   
## [405] "Machamp"                   "Machoke"                  
## [407] "Machop"                    "Magby"                    
## [409] "Magcargo"                  "Magikarp"                 
## [411] "Magmar"                    "Magmortar"                
## [413] "Magnemite"                 "Magneton"                 
## [415] "Magnezone"                 "Makuhita"                 
## [417] "Malamar"                   "Mamoswine"                
## [419] "Manaphy"                   "Mandibuzz"                
## [421] "Manectric"                 "ManectricMega Manectric"  
## [423] "Mankey"                    "Mantine"                  
## [425] "Mantyke"                   "Maractus"                 
## [427] "Mareep"                    "Marill"                   
## [429] "Marowak"                   "Marshtomp"                
## [431] "Masquerain"                "Mawile"                   
## [433] "MawileMega Mawile"         "Medicham"                 
## [435] "MedichamMega Medicham"     "Meditite"                 
## [437] "Meganium"                  "MeloettaAria Forme"       
## [439] "MeloettaPirouette Forme"   "MeowsticFemale"           
## [441] "MeowsticMale"              "Meowth"                   
## [443] "Mesprit"                   "Metagross"                
## [445] "MetagrossMega Metagross"   "Metang"                   
## [447] "Metapod"                   "Mew"                      
## [449] "Mewtwo"                    "MewtwoMega Mewtwo X"      
## [451] "MewtwoMega Mewtwo Y"       "Mienfoo"                  
## [453] "Mienshao"                  "Mightyena"                
## [455] "Milotic"                   "Miltank"                  
## [457] "Mime Jr."                  "Minccino"                 
## [459] "Minun"                     "Misdreavus"               
## [461] "Mismagius"                 "Moltres"                  
## [463] "Monferno"                  "Mothim"                   
## [465] "Mr. Mime"                  "Mudkip"                   
## [467] "Muk"                       "Munchlax"                 
## [469] "Munna"                     "Murkrow"                  
## [471] "Musharna"                  "Natu"                     
## [473] "Nidoking"                  "Nidoqueen"                
## [475] "Nidoranâ<U+0099><U+0082>"                "Nidoranâ<U+0099><U+0080>"               
## [477] "Nidorina"                  "Nidorino"                 
## [479] "Nincada"                   "Ninetales"                
## [481] "Ninjask"                   "Noctowl"                  
## [483] "Noibat"                    "Noivern"                  
## [485] "Nosepass"                  "Numel"                    
## [487] "Nuzleaf"                   "Octillery"                
## [489] "Oddish"                    "Omanyte"                  
## [491] "Omastar"                   "Onix"                     
## [493] "Oshawott"                  "Pachirisu"                
## [495] "Palkia"                    "Palpitoad"                
## [497] "Pancham"                   "Pangoro"                  
## [499] "Panpour"                   "Pansage"                  
## [501] "Pansear"                   "Paras"                    
## [503] "Parasect"                  "Patrat"                   
## [505] "Pawniard"                  "Pelipper"                 
## [507] "Persian"                   "Petilil"                  
## [509] "Phanpy"                    "Phantump"                 
## [511] "Phione"                    "Pichu"                    
## [513] "Pidgeot"                   "PidgeotMega Pidgeot"      
## [515] "Pidgeotto"                 "Pidgey"                   
## [517] "Pidove"                    "Pignite"                  
## [519] "Pikachu"                   "Piloswine"                
## [521] "Pineco"                    "Pinsir"                   
## [523] "PinsirMega Pinsir"         "Piplup"                   
## [525] "Plusle"                    "Politoed"                 
## [527] "Poliwag"                   "Poliwhirl"                
## [529] "Poliwrath"                 "Ponyta"                   
## [531] "Poochyena"                 "Porygon"                  
## [533] "Porygon-Z"                 "Porygon2"                 
## [535] "Primeape"                  "Prinplup"                 
## [537] "Probopass"                 "Psyduck"                  
## [539] "PumpkabooAverage Size"     "PumpkabooLarge Size"      
## [541] "PumpkabooSmall Size"       "PumpkabooSuper Size"      
## [543] "Pupitar"                   "Purrloin"                 
## [545] "Purugly"                   "Pyroar"                   
## [547] "Quagsire"                  "Quilava"                  
## [549] "Quilladin"                 "Qwilfish"                 
## [551] "Raichu"                    "Raikou"                   
## [553] "Ralts"                     "Rampardos"                
## [555] "Rapidash"                  "Raticate"                 
## [557] "Rattata"                   "Rayquaza"                 
## [559] "RayquazaMega Rayquaza"     "Regice"                   
## [561] "Regigigas"                 "Regirock"                 
## [563] "Registeel"                 "Relicanth"                
## [565] "Remoraid"                  "Reshiram"                 
## [567] "Reuniclus"                 "Rhydon"                   
## [569] "Rhyhorn"                   "Rhyperior"                
## [571] "Riolu"                     "Roggenrola"               
## [573] "Roselia"                   "Roserade"                 
## [575] "Rotom"                     "RotomFan Rotom"           
## [577] "RotomFrost Rotom"          "RotomHeat Rotom"          
## [579] "RotomMow Rotom"            "RotomWash Rotom"          
## [581] "Rufflet"                   "Sableye"                  
## [583] "SableyeMega Sableye"       "Salamence"                
## [585] "SalamenceMega Salamence"   "Samurott"                 
## [587] "Sandile"                   "Sandshrew"                
## [589] "Sandslash"                 "Sawk"                     
## [591] "Sawsbuck"                  "Scatterbug"               
## [593] "Sceptile"                  "SceptileMega Sceptile"    
## [595] "Scizor"                    "ScizorMega Scizor"        
## [597] "Scolipede"                 "Scrafty"                  
## [599] "Scraggy"                   "Scyther"                  
## [601] "Seadra"                    "Seaking"                  
## [603] "Sealeo"                    "Seedot"                   
## [605] "Seel"                      "Seismitoad"               
## [607] "Sentret"                   "Serperior"                
## [609] "Servine"                   "Seviper"                  
## [611] "Sewaddle"                  "Sharpedo"                 
## [613] "SharpedoMega Sharpedo"     "ShayminLand Forme"        
## [615] "ShayminSky Forme"          "Shedinja"                 
## [617] "Shelgon"                   "Shellder"                 
## [619] "Shellos"                   "Shelmet"                  
## [621] "Shieldon"                  "Shiftry"                  
## [623] "Shinx"                     "Shroomish"                
## [625] "Shuckle"                   "Shuppet"                  
## [627] "Sigilyph"                  "Silcoon"                  
## [629] "Simipour"                  "Simisage"                 
## [631] "Simisear"                  "Skarmory"                 
## [633] "Skiddo"                    "Skiploom"                 
## [635] "Skitty"                    "Skorupi"                  
## [637] "Skrelp"                    "Skuntank"                 
## [639] "Slaking"                   "Slakoth"                  
## [641] "Sliggoo"                   "Slowbro"                  
## [643] "SlowbroMega Slowbro"       "Slowking"                 
## [645] "Slowpoke"                  "Slugma"                   
## [647] "Slurpuff"                  "Smeargle"                 
## [649] "Smoochum"                  "Sneasel"                  
## [651] "Snivy"                     "Snorlax"                  
## [653] "Snorunt"                   "Snover"                   
## [655] "Snubbull"                  "Solosis"                  
## [657] "Solrock"                   "Spearow"                  
## [659] "Spewpa"                    "Spheal"                   
## [661] "Spinarak"                  "Spinda"                   
## [663] "Spiritomb"                 "Spoink"                   
## [665] "Spritzee"                  "Squirtle"                 
## [667] "Stantler"                  "Staraptor"                
## [669] "Staravia"                  "Starly"                   
## [671] "Starmie"                   "Staryu"                   
## [673] "Steelix"                   "SteelixMega Steelix"      
## [675] "Stoutland"                 "Stunfisk"                 
## [677] "Stunky"                    "Sudowoodo"                
## [679] "Suicune"                   "Sunflora"                 
## [681] "Sunkern"                   "Surskit"                  
## [683] "Swablu"                    "Swadloon"                 
## [685] "Swalot"                    "Swampert"                 
## [687] "SwampertMega Swampert"     "Swanna"                   
## [689] "Swellow"                   "Swinub"                   
## [691] "Swirlix"                   "Swoobat"                  
## [693] "Sylveon"                   "Taillow"                  
## [695] "Talonflame"                "Tangela"                  
## [697] "Tangrowth"                 "Tauros"                   
## [699] "Teddiursa"                 "Tentacool"                
## [701] "Tentacruel"                "Tepig"                    
## [703] "Terrakion"                 "Throh"                    
## [705] "ThundurusIncarnate Forme"  "ThundurusTherian Forme"   
## [707] "Timburr"                   "Tirtouga"                 
## [709] "Togekiss"                  "Togepi"                   
## [711] "Togetic"                   "Torchic"                  
## [713] "Torkoal"                   "TornadusIncarnate Forme"  
## [715] "TornadusTherian Forme"     "Torterra"                 
## [717] "Totodile"                  "Toxicroak"                
## [719] "Tranquill"                 "Trapinch"                 
## [721] "Treecko"                   "Trevenant"                
## [723] "Tropius"                   "Trubbish"                 
## [725] "Turtwig"                   "Tympole"                  
## [727] "Tynamo"                    "Typhlosion"               
## [729] "Tyranitar"                 "TyranitarMega Tyranitar"  
## [731] "Tyrantrum"                 "Tyrogue"                  
## [733] "Tyrunt"                    "Umbreon"                  
## [735] "Unfezant"                  "Unown"                    
## [737] "Ursaring"                  "Uxie"                     
## [739] "Vanillish"                 "Vanillite"                
## [741] "Vanilluxe"                 "Vaporeon"                 
## [743] "Venipede"                  "Venomoth"                 
## [745] "Venonat"                   "Venusaur"                 
## [747] "VenusaurMega Venusaur"     "Vespiquen"                
## [749] "Vibrava"                   "Victini"                  
## [751] "Victreebel"                "Vigoroth"                 
## [753] "Vileplume"                 "Virizion"                 
## [755] "Vivillon"                  "Volbeat"                  
## [757] "Volcanion"                 "Volcarona"                
## [759] "Voltorb"                   "Vullaby"                  
## [761] "Vulpix"                    "Wailmer"                  
## [763] "Wailord"                   "Walrein"                  
## [765] "Wartortle"                 "Watchog"                  
## [767] "Weavile"                   "Weedle"                   
## [769] "Weepinbell"                "Weezing"                  
## [771] "Whimsicott"                "Whirlipede"               
## [773] "Whiscash"                  "Whismur"                  
## [775] "Wigglytuff"                "Wingull"                  
## [777] "Wobbuffet"                 "Woobat"                   
## [779] "Wooper"                    "WormadamPlant Cloak"      
## [781] "WormadamSandy Cloak"       "WormadamTrash Cloak"      
## [783] "Wurmple"                   "Wynaut"                   
## [785] "Xatu"                      "Xerneas"                  
## [787] "Yamask"                    "Yanma"                    
## [789] "Yanmega"                   "Yveltal"                  
## [791] "Zangoose"                  "Zapdos"                   
## [793] "Zebstrika"                 "Zekrom"                   
## [795] "Zigzagoon"                 "Zoroark"                  
## [797] "Zorua"                     "Zubat"                    
## [799] "Zweilous"                  "Zygarde50% Forme"
levels(pokemon$Legendary)
## [1] "False" "True"

Reminder: we convert variables to factor using as.factor()

The end