Google Sheets

Reading data with the googlesheets4 package

First, set up Google credentials.

library(googlesheets4)
# Prompts a browser pop-up
gs4_auth()
# Once set up, you can automate this process by passing your email
gs4_auth(email = "avamariehoffman@gmail.com")

Reading data with the googlesheets4 package

You can also supply an authorization token directly, but make sure never to make these visible online!

library(googledrive)
drive_auth(email= "<email>",
           token = readRDS("google-sheets-token.rds")) # Saved in a file

Reading data with the googlesheets4 package

Read in using read_sheet()

sheet_url <- 
  "https://docs.google.com/spreadsheets/d/1U6Cf_qEOhiR9AZqTqS3mbMF3zt2db48ZP5v3rkrAEJY/edit#gid=780868077"
sheet_dat_1 <- read_sheet(sheet_url)
✔ Reading from "gapminder".
✔ Range 'Africa'.
head(sheet_dat_1)
# A tibble: 6 × 6
  country continent  year lifeExp      pop gdpPercap
  <chr>   <chr>     <dbl>   <dbl>    <dbl>     <dbl>
1 Algeria Africa     1952    43.1  9279525     2449.
2 Algeria Africa     1957    45.7 10270856     3014.
3 Algeria Africa     1962    48.3 11000948     2551.
4 Algeria Africa     1967    51.4 12760499     3247.
5 Algeria Africa     1972    54.5 14760787     4183.
6 Algeria Africa     1977    58.0 17152804     4910.

Reading data with the googlesheets4 package

Specify the sheet name if necessary:

sheet_dat_oceania <- read_sheet(sheet_url, sheet = "Oceania")
✔ Reading from "gapminder".
✔ Range ''Oceania''.
head(sheet_dat_oceania)
# A tibble: 6 × 6
  country   continent  year lifeExp      pop gdpPercap
  <chr>     <chr>     <dbl>   <dbl>    <dbl>     <dbl>
1 Australia Oceania    1952    69.1  8691212    10040.
2 Australia Oceania    1957    70.3  9712569    10950.
3 Australia Oceania    1962    70.9 10794968    12217.
4 Australia Oceania    1967    71.1 11872264    14526.
5 Australia Oceania    1972    71.9 13177000    16789.
6 Australia Oceania    1977    73.5 14074100    18334.

Pull in a subset of data: rows

read_sheet(sheet_url, sheet = "Oceania", range =  cell_rows(1:4))
✔ Reading from "gapminder".
✔ Range ''Oceania'!1:4'.
# A tibble: 3 × 6
  country   continent  year lifeExp      pop gdpPercap
  <chr>     <chr>     <dbl>   <dbl>    <dbl>     <dbl>
1 Australia Oceania    1952    69.1  8691212    10040.
2 Australia Oceania    1957    70.3  9712569    10950.
3 Australia Oceania    1962    70.9 10794968    12217.

Pull in a subset of data: columns

read_sheet(sheet_url, sheet = "Oceania", range =  cell_cols("A:B"))
✔ Reading from "gapminder".
✔ Range ''Oceania'!A:B'.
# A tibble: 24 × 2
   country   continent
   <chr>     <chr>    
 1 Australia Oceania  
 2 Australia Oceania  
 3 Australia Oceania  
 4 Australia Oceania  
 5 Australia Oceania  
 6 Australia Oceania  
 7 Australia Oceania  
 8 Australia Oceania  
 9 Australia Oceania  
10 Australia Oceania  
# ℹ 14 more rows

Reading data with the googlesheets4 package

List out the sheet names using sheet_names().

sheet_names(sheet_url)
[1] "Africa"   "Americas" "Asia"     "Europe"   "Oceania" 

Reading data with the googlesheets4 package

Iterate through the sheet names with purrr:

gapminder_sheets <- sheet_names(sheet_url)

data_list <- map(gapminder_sheets, ~ read_sheet(sheet_url, sheet = .x))
✔ Reading from "gapminder".
✔ Range ''Africa''.
✔ Reading from "gapminder".
✔ Range ''Americas''.
✔ Reading from "gapminder".
✔ Range ''Asia''.
✔ Reading from "gapminder".
✔ Range ''Europe''.
✔ Reading from "gapminder".
✔ Range ''Oceania''.

Reading data with the googlesheets4 package

Check out the list:

str(data_list)
List of 5
 $ : tibble [624 × 6] (S3: tbl_df/tbl/data.frame)
  ..$ country  : chr [1:624] "Algeria" "Algeria" "Algeria" "Algeria" ...
  ..$ continent: chr [1:624] "Africa" "Africa" "Africa" "Africa" ...
  ..$ year     : num [1:624] 1952 1957 1962 1967 1972 ...
  ..$ lifeExp  : num [1:624] 43.1 45.7 48.3 51.4 54.5 ...
  ..$ pop      : num [1:624] 9279525 10270856 11000948 12760499 14760787 ...
  ..$ gdpPercap: num [1:624] 2449 3014 2551 3247 4183 ...
 $ : tibble [300 × 6] (S3: tbl_df/tbl/data.frame)
  ..$ country  : chr [1:300] "Argentina" "Argentina" "Argentina" "Argentina" ...
  ..$ continent: chr [1:300] "Americas" "Americas" "Americas" "Americas" ...
  ..$ year     : num [1:300] 1952 1957 1962 1967 1972 ...
  ..$ lifeExp  : num [1:300] 62.5 64.4 65.1 65.6 67.1 ...
  ..$ pop      : num [1:300] 17876956 19610538 21283783 22934225 24779799 ...
  ..$ gdpPercap: num [1:300] 5911 6857 7133 8053 9443 ...
 $ : tibble [396 × 6] (S3: tbl_df/tbl/data.frame)
  ..$ country  : chr [1:396] "Afghanistan" "Afghanistan" "Afghanistan" "Afghanistan" ...
  ..$ continent: chr [1:396] "Asia" "Asia" "Asia" "Asia" ...
  ..$ year     : num [1:396] 1952 1957 1962 1967 1972 ...
  ..$ lifeExp  : num [1:396] 28.8 30.3 32 34 36.1 ...
  ..$ pop      : num [1:396] 8425333 9240934 10267083 11537966 13079460 ...
  ..$ gdpPercap: num [1:396] 779 821 853 836 740 ...
 $ : tibble [360 × 6] (S3: tbl_df/tbl/data.frame)
  ..$ country  : chr [1:360] "Albania" "Albania" "Albania" "Albania" ...
  ..$ continent: chr [1:360] "Europe" "Europe" "Europe" "Europe" ...
  ..$ year     : num [1:360] 1952 1957 1962 1967 1972 ...
  ..$ lifeExp  : num [1:360] 55.2 59.3 64.8 66.2 67.7 ...
  ..$ pop      : num [1:360] 1282697 1476505 1728137 1984060 2263554 ...
  ..$ gdpPercap: num [1:360] 1601 1942 2313 2760 3313 ...
 $ : tibble [24 × 6] (S3: tbl_df/tbl/data.frame)
  ..$ country  : chr [1:24] "Australia" "Australia" "Australia" "Australia" ...
  ..$ continent: chr [1:24] "Oceania" "Oceania" "Oceania" "Oceania" ...
  ..$ year     : num [1:24] 1952 1957 1962 1967 1972 ...
  ..$ lifeExp  : num [1:24] 69.1 70.3 70.9 71.1 71.9 ...
  ..$ pop      : num [1:24] 8691212 9712569 10794968 11872264 13177000 ...
  ..$ gdpPercap: num [1:24] 10040 10950 12217 14526 16789 ...

Reading data with the googlesheets4 package

Pull out sheets as needed:

data_list[[{sheet}]]
# OR
data_list %>% pluck({sheet})
# OR (if named)
data_list${sheet}

.

Writing data with the googlesheets4 package

sheet_dat_oceania <- data_list[[5]]

sheet_dat_oceania <- sheet_dat_oceania %>%
  mutate(lifeExp_days = lifeExp * 365)

sheet_out <- gs4_create("Oceania-days", 
                       sheets = list(Oceania_days = sheet_dat_oceania))
✔ Creating new Sheet: "Oceania-days".
# Opens a browser window
gs4_browse(sheet_out)

Append data with the googlesheets4 package

sheet_append(sheet_out, data = sheet_dat_oceania, sheet = "Oceania_days")
✔ Writing to "Oceania-days".
✔ Appending 24 rows to 'Oceania_days'.

JHU Tidyverse Book

Lab

JSON: JavaScript Object Notation
Lists of stuff

Why JSON matters

#install.packages("jsonlite")
library(jsonlite)
jsonData <-
  fromJSON("https://raw.githubusercontent.com/Biuni/PokemonGO-Pokedex/master/pokedex.json")
head(jsonData)
$pokemon
     id num               name                                              img
1     1 001          Bulbasaur http://www.serebii.net/pokemongo/pokemon/001.png
2     2 002            Ivysaur http://www.serebii.net/pokemongo/pokemon/002.png
3     3 003           Venusaur http://www.serebii.net/pokemongo/pokemon/003.png
4     4 004         Charmander http://www.serebii.net/pokemongo/pokemon/004.png
5     5 005         Charmeleon http://www.serebii.net/pokemongo/pokemon/005.png
6     6 006          Charizard http://www.serebii.net/pokemongo/pokemon/006.png
7     7 007           Squirtle http://www.serebii.net/pokemongo/pokemon/007.png
8     8 008          Wartortle http://www.serebii.net/pokemongo/pokemon/008.png
9     9 009          Blastoise http://www.serebii.net/pokemongo/pokemon/009.png
10   10 010           Caterpie http://www.serebii.net/pokemongo/pokemon/010.png
11   11 011            Metapod http://www.serebii.net/pokemongo/pokemon/011.png
12   12 012         Butterfree http://www.serebii.net/pokemongo/pokemon/012.png
13   13 013             Weedle http://www.serebii.net/pokemongo/pokemon/013.png
14   14 014             Kakuna http://www.serebii.net/pokemongo/pokemon/014.png
15   15 015           Beedrill http://www.serebii.net/pokemongo/pokemon/015.png
16   16 016             Pidgey http://www.serebii.net/pokemongo/pokemon/016.png
17   17 017          Pidgeotto http://www.serebii.net/pokemongo/pokemon/017.png
18   18 018            Pidgeot http://www.serebii.net/pokemongo/pokemon/018.png
19   19 019            Rattata http://www.serebii.net/pokemongo/pokemon/019.png
20   20 020           Raticate http://www.serebii.net/pokemongo/pokemon/020.png
21   21 021            Spearow http://www.serebii.net/pokemongo/pokemon/021.png
22   22 022             Fearow http://www.serebii.net/pokemongo/pokemon/022.png
23   23 023              Ekans http://www.serebii.net/pokemongo/pokemon/023.png
24   24 024              Arbok http://www.serebii.net/pokemongo/pokemon/024.png
25   25 025            Pikachu http://www.serebii.net/pokemongo/pokemon/025.png
26   26 026             Raichu http://www.serebii.net/pokemongo/pokemon/026.png
27   27 027          Sandshrew http://www.serebii.net/pokemongo/pokemon/027.png
28   28 028          Sandslash http://www.serebii.net/pokemongo/pokemon/028.png
29   29 029 Nidoran ♀ (Female) http://www.serebii.net/pokemongo/pokemon/029.png
30   30 030           Nidorina http://www.serebii.net/pokemongo/pokemon/030.png
31   31 031          Nidoqueen http://www.serebii.net/pokemongo/pokemon/031.png
32   32 032   Nidoran ♂ (Male) http://www.serebii.net/pokemongo/pokemon/032.png
33   33 033           Nidorino http://www.serebii.net/pokemongo/pokemon/033.png
34   34 034           Nidoking http://www.serebii.net/pokemongo/pokemon/034.png
35   35 035           Clefairy http://www.serebii.net/pokemongo/pokemon/035.png
36   36 036           Clefable http://www.serebii.net/pokemongo/pokemon/036.png
37   37 037             Vulpix http://www.serebii.net/pokemongo/pokemon/037.png
38   38 038          Ninetales http://www.serebii.net/pokemongo/pokemon/038.png
39   39 039         Jigglypuff http://www.serebii.net/pokemongo/pokemon/039.png
40   40 040         Wigglytuff http://www.serebii.net/pokemongo/pokemon/040.png
41   41 041              Zubat http://www.serebii.net/pokemongo/pokemon/041.png
42   42 042             Golbat http://www.serebii.net/pokemongo/pokemon/042.png
43   43 043             Oddish http://www.serebii.net/pokemongo/pokemon/043.png
44   44 044              Gloom http://www.serebii.net/pokemongo/pokemon/044.png
45   45 045          Vileplume http://www.serebii.net/pokemongo/pokemon/045.png
46   46 046              Paras http://www.serebii.net/pokemongo/pokemon/046.png
47   47 047           Parasect http://www.serebii.net/pokemongo/pokemon/047.png
48   48 048            Venonat http://www.serebii.net/pokemongo/pokemon/048.png
49   49 049           Venomoth http://www.serebii.net/pokemongo/pokemon/049.png
50   50 050            Diglett http://www.serebii.net/pokemongo/pokemon/050.png
51   51 051            Dugtrio http://www.serebii.net/pokemongo/pokemon/051.png
52   52 052             Meowth http://www.serebii.net/pokemongo/pokemon/052.png
53   53 053            Persian http://www.serebii.net/pokemongo/pokemon/053.png
54   54 054            Psyduck http://www.serebii.net/pokemongo/pokemon/054.png
55   55 055            Golduck http://www.serebii.net/pokemongo/pokemon/055.png
56   56 056             Mankey http://www.serebii.net/pokemongo/pokemon/056.png
57   57 057           Primeape http://www.serebii.net/pokemongo/pokemon/057.png
58   58 058          Growlithe http://www.serebii.net/pokemongo/pokemon/058.png
59   59 059           Arcanine http://www.serebii.net/pokemongo/pokemon/059.png
60   60 060            Poliwag http://www.serebii.net/pokemongo/pokemon/060.png
61   61 061          Poliwhirl http://www.serebii.net/pokemongo/pokemon/061.png
62   62 062          Poliwrath http://www.serebii.net/pokemongo/pokemon/062.png
63   63 063               Abra http://www.serebii.net/pokemongo/pokemon/063.png
64   64 064            Kadabra http://www.serebii.net/pokemongo/pokemon/064.png
65   65 065           Alakazam http://www.serebii.net/pokemongo/pokemon/065.png
66   66 066             Machop http://www.serebii.net/pokemongo/pokemon/066.png
67   67 067            Machoke http://www.serebii.net/pokemongo/pokemon/067.png
68   68 068            Machamp http://www.serebii.net/pokemongo/pokemon/068.png
69   69 069         Bellsprout http://www.serebii.net/pokemongo/pokemon/069.png
70   70 070         Weepinbell http://www.serebii.net/pokemongo/pokemon/070.png
71   71 071         Victreebel http://www.serebii.net/pokemongo/pokemon/071.png
72   72 072          Tentacool http://www.serebii.net/pokemongo/pokemon/072.png
73   73 073         Tentacruel http://www.serebii.net/pokemongo/pokemon/073.png
74   74 074            Geodude http://www.serebii.net/pokemongo/pokemon/074.png
75   75 075           Graveler http://www.serebii.net/pokemongo/pokemon/075.png
76   76 076              Golem http://www.serebii.net/pokemongo/pokemon/076.png
77   77 077             Ponyta http://www.serebii.net/pokemongo/pokemon/077.png
78   78 078           Rapidash http://www.serebii.net/pokemongo/pokemon/078.png
79   79 079           Slowpoke http://www.serebii.net/pokemongo/pokemon/079.png
80   80 080            Slowbro http://www.serebii.net/pokemongo/pokemon/080.png
81   81 081          Magnemite http://www.serebii.net/pokemongo/pokemon/081.png
82   82 082           Magneton http://www.serebii.net/pokemongo/pokemon/082.png
83   83 083         Farfetch'd http://www.serebii.net/pokemongo/pokemon/083.png
84   84 084              Doduo http://www.serebii.net/pokemongo/pokemon/084.png
85   85 085             Dodrio http://www.serebii.net/pokemongo/pokemon/085.png
86   86 086               Seel http://www.serebii.net/pokemongo/pokemon/086.png
87   87 087            Dewgong http://www.serebii.net/pokemongo/pokemon/087.png
88   88 088             Grimer http://www.serebii.net/pokemongo/pokemon/088.png
89   89 089                Muk http://www.serebii.net/pokemongo/pokemon/089.png
90   90 090           Shellder http://www.serebii.net/pokemongo/pokemon/090.png
91   91 091           Cloyster http://www.serebii.net/pokemongo/pokemon/091.png
92   92 092             Gastly http://www.serebii.net/pokemongo/pokemon/092.png
93   93 093            Haunter http://www.serebii.net/pokemongo/pokemon/093.png
94   94 094             Gengar http://www.serebii.net/pokemongo/pokemon/094.png
95   95 095               Onix http://www.serebii.net/pokemongo/pokemon/095.png
96   96 096            Drowzee http://www.serebii.net/pokemongo/pokemon/096.png
97   97 097              Hypno http://www.serebii.net/pokemongo/pokemon/097.png
98   98 098             Krabby http://www.serebii.net/pokemongo/pokemon/098.png
99   99 099            Kingler http://www.serebii.net/pokemongo/pokemon/099.png
100 100 100            Voltorb http://www.serebii.net/pokemongo/pokemon/100.png
101 101 101          Electrode http://www.serebii.net/pokemongo/pokemon/101.png
102 102 102          Exeggcute http://www.serebii.net/pokemongo/pokemon/102.png
103 103 103          Exeggutor http://www.serebii.net/pokemongo/pokemon/103.png
104 104 104             Cubone http://www.serebii.net/pokemongo/pokemon/104.png
105 105 105            Marowak http://www.serebii.net/pokemongo/pokemon/105.png
106 106 106          Hitmonlee http://www.serebii.net/pokemongo/pokemon/106.png
107 107 107         Hitmonchan http://www.serebii.net/pokemongo/pokemon/107.png
108 108 108          Lickitung http://www.serebii.net/pokemongo/pokemon/108.png
109 109 109            Koffing http://www.serebii.net/pokemongo/pokemon/109.png
110 110 110            Weezing http://www.serebii.net/pokemongo/pokemon/110.png
111 111 111            Rhyhorn http://www.serebii.net/pokemongo/pokemon/111.png
112 112 112             Rhydon http://www.serebii.net/pokemongo/pokemon/112.png
113 113 113            Chansey http://www.serebii.net/pokemongo/pokemon/113.png
114 114 114            Tangela http://www.serebii.net/pokemongo/pokemon/114.png
115 115 115         Kangaskhan http://www.serebii.net/pokemongo/pokemon/115.png
116 116 116             Horsea http://www.serebii.net/pokemongo/pokemon/116.png
117 117 117             Seadra http://www.serebii.net/pokemongo/pokemon/117.png
118 118 118            Goldeen http://www.serebii.net/pokemongo/pokemon/118.png
119 119 119            Seaking http://www.serebii.net/pokemongo/pokemon/119.png
120 120 120             Staryu http://www.serebii.net/pokemongo/pokemon/120.png
121 121 121            Starmie http://www.serebii.net/pokemongo/pokemon/121.png
122 122 122           Mr. Mime http://www.serebii.net/pokemongo/pokemon/122.png
123 123 123            Scyther http://www.serebii.net/pokemongo/pokemon/123.png
124 124 124               Jynx http://www.serebii.net/pokemongo/pokemon/124.png
125 125 125         Electabuzz http://www.serebii.net/pokemongo/pokemon/125.png
126 126 126             Magmar http://www.serebii.net/pokemongo/pokemon/126.png
127 127 127             Pinsir http://www.serebii.net/pokemongo/pokemon/127.png
128 128 128             Tauros http://www.serebii.net/pokemongo/pokemon/128.png
129 129 129           Magikarp http://www.serebii.net/pokemongo/pokemon/129.png
130 130 130           Gyarados http://www.serebii.net/pokemongo/pokemon/130.png
131 131 131             Lapras http://www.serebii.net/pokemongo/pokemon/131.png
132 132 132              Ditto http://www.serebii.net/pokemongo/pokemon/132.png
133 133 133              Eevee http://www.serebii.net/pokemongo/pokemon/133.png
134 134 134           Vaporeon http://www.serebii.net/pokemongo/pokemon/134.png
135 135 135            Jolteon http://www.serebii.net/pokemongo/pokemon/135.png
136 136 136            Flareon http://www.serebii.net/pokemongo/pokemon/136.png
137 137 137            Porygon http://www.serebii.net/pokemongo/pokemon/137.png
138 138 138            Omanyte http://www.serebii.net/pokemongo/pokemon/138.png
139 139 139            Omastar http://www.serebii.net/pokemongo/pokemon/139.png
140 140 140             Kabuto http://www.serebii.net/pokemongo/pokemon/140.png
141 141 141           Kabutops http://www.serebii.net/pokemongo/pokemon/141.png
142 142 142         Aerodactyl http://www.serebii.net/pokemongo/pokemon/142.png
143 143 143            Snorlax http://www.serebii.net/pokemongo/pokemon/143.png
144 144 144           Articuno http://www.serebii.net/pokemongo/pokemon/144.png
145 145 145             Zapdos http://www.serebii.net/pokemongo/pokemon/145.png
146 146 146            Moltres http://www.serebii.net/pokemongo/pokemon/146.png
147 147 147            Dratini http://www.serebii.net/pokemongo/pokemon/147.png
148 148 148          Dragonair http://www.serebii.net/pokemongo/pokemon/148.png
149 149 149          Dragonite http://www.serebii.net/pokemongo/pokemon/149.png
150 150 150             Mewtwo http://www.serebii.net/pokemongo/pokemon/150.png
151 151 151                Mew http://www.serebii.net/pokemongo/pokemon/151.png
                type height   weight                    candy candy_count
1      Grass, Poison 0.71 m   6.9 kg          Bulbasaur Candy          25
2      Grass, Poison 0.99 m  13.0 kg          Bulbasaur Candy         100
3      Grass, Poison 2.01 m 100.0 kg          Bulbasaur Candy          NA
4               Fire 0.61 m   8.5 kg         Charmander Candy          25
5               Fire 1.09 m  19.0 kg         Charmander Candy         100
6       Fire, Flying 1.70 m  90.5 kg         Charmander Candy          NA
7              Water 0.51 m   9.0 kg           Squirtle Candy          25
8              Water 0.99 m  22.5 kg           Squirtle Candy         100
9              Water 1.60 m  85.5 kg           Squirtle Candy          NA
10               Bug 0.30 m   2.9 kg           Caterpie Candy          12
11               Bug 0.71 m   9.9 kg           Caterpie Candy          50
12       Bug, Flying 1.09 m  32.0 kg           Caterpie Candy          NA
13       Bug, Poison 0.30 m   3.2 kg             Weedle Candy          12
14       Bug, Poison 0.61 m  10.0 kg             Weedle Candy          50
15       Bug, Poison 0.99 m  29.5 kg             Weedle Candy          NA
16    Normal, Flying 0.30 m   1.8 kg             Pidgey Candy          12
17    Normal, Flying 1.09 m  30.0 kg             Pidgey Candy          50
18    Normal, Flying 1.50 m  39.5 kg             Pidgey Candy          NA
19            Normal 0.30 m   3.5 kg            Rattata Candy          25
20            Normal 0.71 m  18.5 kg            Rattata Candy          NA
21    Normal, Flying 0.30 m   2.0 kg            Spearow Candy          50
22    Normal, Flying 1.19 m  38.0 kg            Spearow Candy          NA
23            Poison 2.01 m   6.9 kg              Ekans Candy          50
24            Poison 3.51 m  65.0 kg              Ekans Candy          NA
25          Electric 0.41 m   6.0 kg            Pikachu Candy          50
26          Electric 0.79 m  30.0 kg            Pikachu Candy          NA
27            Ground 0.61 m  12.0 kg          Sandshrew Candy          50
28            Ground 0.99 m  29.5 kg          Sandshrew Candy          NA
29            Poison 0.41 m   7.0 kg Nidoran ♀ (Female) Candy          25
30            Poison 0.79 m  20.0 kg Nidoran ♀ (Female) Candy         100
31    Poison, Ground 1.30 m  60.0 kg Nidoran ♀ (Female) Candy          NA
32            Poison 0.51 m   9.0 kg   Nidoran ♂ (Male) Candy          25
33            Poison 0.89 m  19.5 kg   Nidoran ♂ (Male) Candy         100
34    Poison, Ground 1.40 m  62.0 kg   Nidoran ♂ (Male) Candy          NA
35            Normal 0.61 m   7.5 kg           Clefairy Candy          50
36            Normal 1.30 m  40.0 kg           Clefairy Candy          NA
37              Fire 0.61 m   9.9 kg             Vulpix Candy          50
38              Fire 1.09 m  19.9 kg             Vulpix Candy          NA
39            Normal 0.51 m   5.5 kg         Jigglypuff Candy          50
40            Normal 0.99 m  12.0 kg         Jigglypuff Candy          NA
41    Poison, Flying 0.79 m   7.5 kg              Zubat Candy          50
42    Poison, Flying 1.60 m  55.0 kg              Zubat Candy          NA
43     Grass, Poison 0.51 m   5.4 kg             Oddish Candy          25
44     Grass, Poison 0.79 m   8.6 kg             Oddish Candy         100
45     Grass, Poison 1.19 m  18.6 kg             Oddish Candy          NA
46        Bug, Grass 0.30 m   5.4 kg              Paras Candy          50
47        Bug, Grass 0.99 m  29.5 kg              Paras Candy          NA
48       Bug, Poison 0.99 m  30.0 kg            Venonat Candy          50
49       Bug, Poison 1.50 m  12.5 kg            Venonat Candy          NA
50            Ground 0.20 m   0.8 kg            Diglett Candy          50
51            Ground 0.71 m  33.3 kg                  Dugtrio          NA
52            Normal 0.41 m   4.2 kg             Meowth Candy          50
53            Normal 0.99 m  32.0 kg             Meowth Candy          NA
54             Water 0.79 m  19.6 kg            Psyduck Candy          50
55             Water 1.70 m  76.6 kg            Psyduck Candy          NA
56          Fighting 0.51 m  28.0 kg             Mankey Candy          50
57          Fighting 0.99 m  32.0 kg             Mankey Candy          NA
58              Fire 0.71 m  19.0 kg          Growlithe Candy          50
59              Fire 1.91 m 155.0 kg          Growlithe Candy          NA
60             Water 0.61 m  12.4 kg            Poliwag Candy          25
61             Water 0.99 m  20.0 kg            Poliwag Candy         100
62   Water, Fighting 1.30 m  54.0 kg            Poliwag Candy          NA
63           Psychic 0.89 m  19.5 kg               Abra Candy          25
64           Psychic 1.30 m  56.5 kg               Abra Candy         100
65           Psychic 1.50 m  48.0 kg               Abra Candy          NA
66          Fighting 0.79 m  19.5 kg             Machop Candy          25
67          Fighting 1.50 m  70.5 kg             Machop Candy         100
68          Fighting 1.60 m 130.0 kg             Machop Candy          NA
69     Grass, Poison 0.71 m   4.0 kg         Bellsprout Candy          25
70     Grass, Poison 0.99 m   6.4 kg         Bellsprout Candy         100
71     Grass, Poison 1.70 m  15.5 kg         Bellsprout Candy          NA
72     Water, Poison 0.89 m  45.5 kg          Tentacool Candy          50
73     Water, Poison 1.60 m  55.0 kg          Tentacool Candy          NA
74      Rock, Ground 0.41 m  20.0 kg            Geodude Candy          25
75      Rock, Ground 0.99 m 105.0 kg            Geodude Candy         100
76      Rock, Ground 1.40 m 300.0 kg            Geodude Candy          NA
77              Fire 0.99 m  30.0 kg             Ponyta Candy          50
78              Fire 1.70 m  95.0 kg             Ponyta Candy          NA
79    Water, Psychic 1.19 m  36.0 kg           Slowpoke Candy          50
80    Water, Psychic 1.60 m  78.5 kg           Slowpoke Candy          NA
81          Electric 0.30 m   6.0 kg          Magnemite Candy          50
82          Electric 0.99 m  60.0 kg          Magnemite Candy          NA
83    Normal, Flying 0.79 m  15.0 kg                     None          NA
84    Normal, Flying 1.40 m  39.2 kg              Doduo Candy          50
85    Normal, Flying 1.80 m  85.2 kg              Doduo Candy          NA
86             Water 1.09 m  90.0 kg               Seel Candy          50
87        Water, Ice 1.70 m 120.0 kg               Seel Candy          NA
88            Poison 0.89 m  30.0 kg             Grimer Candy          50
89            Poison 1.19 m  30.0 kg             Grimer Candy          NA
90             Water 0.30 m   4.0 kg           Shellder Candy          50
91        Water, Ice 1.50 m 132.5 kg           Shellder Candy          NA
92     Ghost, Poison 1.30 m   0.1 kg             Gastly Candy          25
93     Ghost, Poison 1.60 m   0.1 kg             Gastly Candy         100
94     Ghost, Poison 1.50 m  40.5 kg             Gastly Candy          NA
95      Rock, Ground 8.79 m 210.0 kg                     None          NA
96           Psychic 0.99 m  32.4 kg            Drowzee Candy          50
97           Psychic 1.60 m  75.6 kg            Drowzee Candy          NA
98             Water 0.41 m   6.5 kg             Krabby Candy          50
99             Water 1.30 m  60.0 kg             Krabby Candy          NA
100         Electric 0.51 m  10.4 kg            Voltorb Candy          50
101         Electric 1.19 m  66.6 kg            Voltorb Candy          NA
102   Grass, Psychic 0.41 m   2.5 kg          Exeggcute Candy          50
103   Grass, Psychic 2.01 m 120.0 kg          Exeggcute Candy          NA
104           Ground 0.41 m   6.5 kg             Cubone Candy          50
105           Ground 0.99 m  45.0 kg             Cubone Candy          NA
106         Fighting 1.50 m  49.8 kg                     None          NA
107         Fighting 1.40 m  50.2 kg                     None          NA
108           Normal 1.19 m  65.5 kg                     None          NA
109           Poison 0.61 m   1.0 kg            Koffing Candy          50
110           Poison 1.19 m   9.5 kg            Koffing Candy          NA
111     Ground, Rock 0.99 m 115.0 kg            Rhyhorn Candy          50
112     Ground, Rock 1.91 m 120.0 kg            Rhyhorn Candy          NA
113           Normal 1.09 m  34.6 kg                     None          NA
114            Grass 0.99 m  35.0 kg                     None          NA
115           Normal 2.21 m  80.0 kg                     None          NA
116            Water 0.41 m   8.0 kg             Horsea Candy          50
117            Water 1.19 m  25.0 kg             Horsea Candy          NA
118            Water 0.61 m  15.0 kg            Goldeen Candy          50
119            Water 1.30 m  39.0 kg            Goldeen Candy          NA
120            Water 0.79 m  34.5 kg             Staryu Candy          50
121   Water, Psychic 1.09 m  80.0 kg             Staryu Candy          NA
122          Psychic 1.30 m  54.5 kg                     None          NA
123      Bug, Flying 1.50 m  56.0 kg                     None          NA
124     Ice, Psychic 1.40 m  40.6 kg                     None          NA
125         Electric 1.09 m  30.0 kg                     None          NA
126             Fire 1.30 m  44.5 kg                     None          NA
127              Bug 1.50 m  55.0 kg                     None          NA
128           Normal 1.40 m  88.4 kg                     None          NA
129            Water 0.89 m  10.0 kg           Magikarp Candy         400
130    Water, Flying 6.50 m 235.0 kg           Magikarp Candy          NA
131       Water, Ice 2.49 m 220.0 kg                     None          NA
132           Normal 0.30 m   4.0 kg                     None          NA
133           Normal 0.30 m   6.5 kg              Eevee Candy          25
134            Water 0.99 m  29.0 kg              Eevee Candy          NA
135         Electric 0.79 m  24.5 kg                     None          NA
136             Fire 0.89 m  25.0 kg              Eevee Candy          NA
137           Normal 0.79 m  36.5 kg                     None          NA
138      Rock, Water 0.41 m   7.5 kg            Omanyte Candy          50
139      Rock, Water 0.99 m  35.0 kg                     None          NA
140      Rock, Water 0.51 m  11.5 kg             Kabuto Candy          50
141      Rock, Water 1.30 m  40.5 kg             Kabuto Candy          NA
142     Rock, Flying 1.80 m  59.0 kg                     None          NA
143           Normal 2.11 m 460.0 kg                     None          NA
144      Ice, Flying 1.70 m  55.4 kg                     None          NA
145 Electric, Flying 1.60 m  52.6 kg                     None          NA
146     Fire, Flying 2.01 m  60.0 kg                     None          NA
147           Dragon 1.80 m   3.3 kg            Dratini Candy          25
148           Dragon 3.99 m  16.5 kg            Dratini Candy         100
149   Dragon, Flying 2.21 m 210.0 kg            Dratini Candy          NA
150          Psychic 2.01 m 122.0 kg                     None          NA
151          Psychic 0.41 m   4.0 kg                     None          NA
              egg spawn_chance avg_spawns spawn_time multipliers
1            2 km       0.6900     69.000      20:00        1.58
2     Not in Eggs       0.0420      4.200      07:00    1.2, 1.6
3     Not in Eggs       0.0170      1.700      11:30        NULL
4            2 km       0.2530     25.300      08:45        1.65
5     Not in Eggs       0.0120      1.200      19:00        1.79
6     Not in Eggs       0.0031      0.310      13:34        NULL
7            2 km       0.5800     58.000      04:25         2.1
8     Not in Eggs       0.0340      3.400      07:02         1.4
9     Not in Eggs       0.0067      0.670      00:06        NULL
10           2 km       3.0320    303.200      16:35        1.05
11    Not in Eggs       0.1870     18.700      02:11  3.55, 3.79
12    Not in Eggs       0.0220      2.200      05:23        NULL
13           2 km       7.1200    712.000      02:21  1.01, 1.09
14    Not in Eggs       0.4400     44.000      02:30  3.01, 3.41
15    Not in Eggs       0.0510      5.100      04:50        NULL
16           2 km      15.9800      1.598      01:34  1.71, 1.92
17    Not in Eggs       1.0200    102.000      01:30        1.79
18    Not in Eggs       0.1300     13.000      01:50        NULL
19           2 km      13.0500      1.305      01:55  2.55, 2.73
20    Not in Eggs       0.4100     41.000      01:56        NULL
21           2 km       4.7300    473.000      12:25  2.66, 2.68
22    Not in Eggs       0.1500     15.000      01:11        NULL
23           5 km       2.2700    227.000      12:20  2.21, 2.27
24    Not in Eggs       0.0720      7.200      01:50        NULL
25           2 km       0.2100     21.000      04:00        2.34
26    Not in Eggs       0.0076      0.760      23:58        NULL
27           5 km       1.1100    111.000      01:58        2.45
28    Not in Eggs       0.0370      3.700      12:34        NULL
29           5 km       1.3800    138.000      01:51  1.63, 2.48
30    Not in Eggs       0.0880      8.800      07:22  1.83, 2.48
31    Not in Eggs       0.0120      1.200      12:35        NULL
32           5 km       1.3100    131.000      01:12  1.64, 1.70
33    Not in Eggs       0.0830      8.300      09:02        1.83
34    Not in Eggs       0.0170      1.700      12:16        NULL
35           2 km       0.9200     92.000      03:30  2.03, 2.14
36    Not in Eggs       0.0120      1.200      03:29        NULL
37           5 km       0.2200     22.000      13:43  2.74, 2.81
38    Not in Eggs       0.0077      0.770      01:32        NULL
39           2 km       0.3900     39.000      08:46        1.85
40    Not in Eggs       0.0180      1.800      12:28        NULL
41           2 km       6.5200    652.000      12:28  2.60, 3.67
42    Not in Eggs       0.4200     42.000      02:15        NULL
43           5 km       1.0200    102.000      03:58         1.5
44    Not in Eggs       0.0640      6.400      11:33        1.49
45    Not in Eggs       0.0097      0.970      23:58        NULL
46           5 km       2.3600    236.000      01:42        2.02
47    Not in Eggs       0.0740      7.400      01:22        NULL
48           5 km       2.2800    228.000      02:31  1.86, 1.90
49    Not in Eggs       0.0720      7.200      23:40        NULL
50           5 km       0.4000     40.000      02:22        2.69
51    Not in Eggs       0.0140      1.400      12:37        NULL
52           5 km       0.8600     86.000      02:54        1.98
53    Not in Eggs       0.0220      2.200      02:44        NULL
54           5 km       2.5400    254.000      03:41        2.27
55    Not in Eggs       0.0870      8.700      23:06        NULL
56           5 km       0.9200     92.000      12:52  2.17, 2.28
57    Not in Eggs       0.0310      3.100      12:33        NULL
58           5 km       0.9200     92.000      03:57  2.31, 2.36
59    Not in Eggs       0.0170      1.700      03:11        NULL
60           5 km       2.1900    219.000      03:40  1.72, 1.73
61    Not in Eggs       0.1300     13.000      09:14        1.95
62    Not in Eggs       0.0110      1.100      01:32        NULL
63           5 km       0.4200     42.000      04:30  1.36, 1.95
64    Not in Eggs       0.0270      2.700      11:25         1.4
65    Not in Eggs       0.0073      0.730      12:33        NULL
66           5 km       0.4900     49.000      01:55  1.64, 1.65
67    Not in Eggs       0.0340      3.400      10:32         1.7
68    Not in Eggs       0.0068      0.680      02:55        NULL
69           5 km       1.1500    115.000      04:10        1.57
70    Not in Eggs       0.0720      7.200      09:45        1.59
71    Not in Eggs       0.0059      0.590      12:19        NULL
72           5 km       0.8100     81.000      03:20        2.52
73    Not in Eggs       0.0820      8.200      23:36        NULL
74           2 km       1.1900    119.000      12:40  1.75, 1.76
75    Not in Eggs       0.0710      7.100      04:53  1.64, 1.72
76    Not in Eggs       0.0047      0.470      12:16        NULL
77           5 km       0.5100     51.000      02:50  1.48, 1.50
78    Not in Eggs       0.0110      1.100      04:00        NULL
79           5 km       1.0500    105.000      07:12        2.21
80    Not in Eggs       0.0360      3.600      02:56        NULL
81           5 km       0.7100     71.000      04:04  2.16, 2.17
82    Not in Eggs       0.0230      2.300      15:25        NULL
83           5 km       0.0212      2.120      01:09        NULL
84           5 km       0.5200     52.000      05:10  2.19, 2.24
85    Not in Eggs       0.2200     22.000      02:12        NULL
86           5 km       0.2800     28.000      06:46  1.04, 1.96
87    Not in Eggs       0.0130      1.300      06:04        NULL
88           5 km       0.0520      5.200      15:11        2.44
89    Not in Eggs       0.0031      0.310      01:28        NULL
90           5 km       0.5200     52.000      07:39        2.65
91    Not in Eggs       0.0150      1.500      02:33        NULL
92           5 km       0.7900     79.000      04:21        1.78
93    Not in Eggs       0.0520      5.200      00:10  1.56, 1.80
94    Not in Eggs       0.0067      0.670      03:55        NULL
95          10 km       0.1000     10.000      01:18        NULL
96           5 km       3.2100    321.000      01:51  2.08, 2.09
97    Not in Eggs       0.1000     10.000      02:17        NULL
98           5 km       2.1200    212.000      03:33  2.36, 2.40
99    Not in Eggs       0.0620      6.200      03:44        NULL
100          5 km       0.6500     65.000      04:36  2.01, 2.02
101   Not in Eggs       0.0200      2.000      04:10        NULL
102          5 km       0.7800     78.000      09:09  2.70, 3.18
103   Not in Eggs       0.0140      1.400      12:34        NULL
104          5 km       0.6100     61.000      01:51        1.67
105   Not in Eggs       0.0200      2.000      03:59        NULL
106         10 km       0.0200      2.000      03:59        NULL
107         10 km       0.0220      2.200      05:58        NULL
108          5 km       0.0110      1.100      02:46        NULL
109          5 km       0.2000     20.000      08:16        1.11
110   Not in Eggs       0.0160      1.600      12:17        NULL
111          5 km       0.6300     63.000      03:21        1.91
112   Not in Eggs       0.0220      2.200      05:50        NULL
113         10 km       0.0130      1.300      04:46        NULL
114          5 km       0.2280     22.800      23:13        NULL
115          5 km       0.0086      0.860      02:40        NULL
116          5 km       1.1300    113.000      02:53        2.23
117   Not in Eggs       0.0340      3.400      03:18        NULL
118          5 km       2.1800    218.000      03:14  2.15, 2.20
119   Not in Eggs       0.0800      8.000      05:21        NULL
120          5 km       1.9500    195.000      22:59  2.38, 2.41
121   Not in Eggs       0.0340      3.400      06:57        NULL
122         10 km       0.0031      0.310      01:51        NULL
123         10 km       0.1400     14.000      05:43        NULL
124         10 km       0.3500     35.000      05:41        NULL
125         10 km       0.0740      7.400      04:28        NULL
126         10 km       0.1000     10.000      20:36        NULL
127         10 km       0.9900     99.000      03:25        NULL
128          5 km       0.1200     12.000      00:37        NULL
129          2 km       4.7800    478.000      14:26  10.1, 11.8
130   Not in Eggs       0.0032      0.320      02:15        NULL
131         10 km       0.0060      0.600      08:59        NULL
132   Not in Eggs       0.0000      0.000        N/A        NULL
133         10 km       2.7500    275.000      05:32  2.02, 2.64
134   Not in Eggs       0.0140      1.400      10:54        NULL
135   Not in Eggs       0.0120      1.200      02:30        NULL
136   Not in Eggs       0.0170      1.700      07:02        NULL
137          5 km       0.0120      1.200      02:49        NULL
138         10 km       0.1400     14.000      10:23        2.12
139 Omanyte Candy       0.0061      0.610      05:04        NULL
140         10 km       0.1000     10.000      00:05  1.97, 2.37
141   Not in Eggs       0.0032      0.320      23:40        NULL
142         10 km       0.0180      1.800      23:40        NULL
143         10 km       0.0160      1.600      23:40        NULL
144   Not in Eggs       0.0000      0.000        N/A        NULL
145   Not in Eggs       0.0000      0.000        N/A        NULL
146   Not in Eggs       0.0000      0.000        N/A        NULL
147         10 km       0.3000     30.000      06:41  1.83, 1.84
148   Not in Eggs       0.0200      2.000      11:57        2.05
149   Not in Eggs       0.0011      0.110      23:38        NULL
150   Not in Eggs       0.0000      0.000        N/A        NULL
151   Not in Eggs       0.0000      0.000        N/A        NULL
                                     weaknesses
1                    Fire, Ice, Flying, Psychic
2                    Fire, Ice, Flying, Psychic
3                    Fire, Ice, Flying, Psychic
4                           Water, Ground, Rock
5                           Water, Ground, Rock
6                         Water, Electric, Rock
7                               Electric, Grass
8                               Electric, Grass
9                               Electric, Grass
10                           Fire, Flying, Rock
11                           Fire, Flying, Rock
12            Fire, Electric, Ice, Flying, Rock
13                  Fire, Flying, Psychic, Rock
14                  Fire, Flying, Psychic, Rock
15                  Fire, Flying, Psychic, Rock
16                               Electric, Rock
17                               Electric, Rock
18                               Electric, Rock
19                                     Fighting
20                                     Fighting
21                               Electric, Rock
22                               Electric, Rock
23                              Ground, Psychic
24                              Ground, Psychic
25                                       Ground
26                                       Ground
27                            Water, Grass, Ice
28                            Water, Grass, Ice
29                              Ground, Psychic
30                              Ground, Psychic
31                  Water, Ice, Ground, Psychic
32                              Ground, Psychic
33                              Ground, Psychic
34                  Water, Ice, Ground, Psychic
35                                     Fighting
36                                     Fighting
37                          Water, Ground, Rock
38                          Water, Ground, Rock
39                                     Fighting
40                                     Fighting
41                 Electric, Ice, Psychic, Rock
42                 Electric, Ice, Psychic, Rock
43                   Fire, Ice, Flying, Psychic
44                   Fire, Ice, Flying, Psychic
45                   Fire, Ice, Flying, Psychic
46         Fire, Ice, Poison, Flying, Bug, Rock
47         Fire, Ice, Poison, Flying, Bug, Rock
48                  Fire, Flying, Psychic, Rock
49                  Fire, Flying, Psychic, Rock
50                            Water, Grass, Ice
51                            Water, Grass, Ice
52                                     Fighting
53                                     Fighting
54                              Electric, Grass
55                              Electric, Grass
56                       Flying, Psychic, Fairy
57                       Flying, Psychic, Fairy
58                          Water, Ground, Rock
59                          Water, Ground, Rock
60                              Electric, Grass
61                              Electric, Grass
62      Electric, Grass, Flying, Psychic, Fairy
63                             Bug, Ghost, Dark
64                             Bug, Ghost, Dark
65                             Bug, Ghost, Dark
66                       Flying, Psychic, Fairy
67                       Flying, Psychic, Fairy
68                       Flying, Psychic, Fairy
69                   Fire, Ice, Flying, Psychic
70                   Fire, Ice, Flying, Psychic
71                   Fire, Ice, Flying, Psychic
72                    Electric, Ground, Psychic
73                    Electric, Ground, Psychic
74   Water, Grass, Ice, Fighting, Ground, Steel
75   Water, Grass, Ice, Fighting, Ground, Steel
76   Water, Grass, Ice, Fighting, Ground, Steel
77                          Water, Ground, Rock
78                          Water, Ground, Rock
79            Electric, Grass, Bug, Ghost, Dark
80            Electric, Grass, Bug, Ghost, Dark
81                          Fire, Water, Ground
82                          Fire, Water, Ground
83                               Electric, Rock
84                               Electric, Rock
85                               Electric, Rock
86                              Electric, Grass
87              Electric, Grass, Fighting, Rock
88                              Ground, Psychic
89                              Ground, Psychic
90                              Electric, Grass
91              Electric, Grass, Fighting, Rock
92                 Ground, Psychic, Ghost, Dark
93                 Ground, Psychic, Ghost, Dark
94                 Ground, Psychic, Ghost, Dark
95   Water, Grass, Ice, Fighting, Ground, Steel
96                             Bug, Ghost, Dark
97                             Bug, Ghost, Dark
98                              Electric, Grass
99                              Electric, Grass
100                                      Ground
101                                      Ground
102 Fire, Ice, Poison, Flying, Bug, Ghost, Dark
103 Fire, Ice, Poison, Flying, Bug, Ghost, Dark
104                           Water, Grass, Ice
105                           Water, Grass, Ice
106                      Flying, Psychic, Fairy
107                      Flying, Psychic, Fairy
108                                    Fighting
109                             Ground, Psychic
110                             Ground, Psychic
111  Water, Grass, Ice, Fighting, Ground, Steel
112  Water, Grass, Ice, Fighting, Ground, Steel
113                                    Fighting
114              Fire, Ice, Poison, Flying, Bug
115                                    Fighting
116                             Electric, Grass
117                             Electric, Grass
118                             Electric, Grass
119                             Electric, Grass
120                             Electric, Grass
121           Electric, Grass, Bug, Ghost, Dark
122                            Bug, Ghost, Dark
123           Fire, Electric, Ice, Flying, Rock
124         Fire, Bug, Rock, Ghost, Dark, Steel
125                                      Ground
126                         Water, Ground, Rock
127                          Fire, Flying, Rock
128                                    Fighting
129                             Electric, Grass
130                              Electric, Rock
131             Electric, Grass, Fighting, Rock
132                                    Fighting
133                                    Fighting
134                             Electric, Grass
135                                      Ground
136                         Water, Ground, Rock
137                                    Fighting
138           Electric, Grass, Fighting, Ground
139           Electric, Grass, Fighting, Ground
140           Electric, Grass, Fighting, Ground
141           Electric, Grass, Fighting, Ground
142           Water, Electric, Ice, Rock, Steel
143                                    Fighting
144                 Fire, Electric, Rock, Steel
145                                   Ice, Rock
146                       Water, Electric, Rock
147                          Ice, Dragon, Fairy
148                          Ice, Dragon, Fairy
149                    Ice, Rock, Dragon, Fairy
150                            Bug, Ghost, Dark
151                            Bug, Ghost, Dark
                               next_evolution
1                 002, 003, Ivysaur, Venusaur
2                               003, Venusaur
3                                        NULL
4             005, 006, Charmeleon, Charizard
5                              006, Charizard
6                                        NULL
7              008, 009, Wartortle, Blastoise
8                              009, Blastoise
9                                        NULL
10              011, 012, Metapod, Butterfree
11                            012, Butterfree
12                                       NULL
13                 014, 015, Kakuna, Beedrill
14                              015, Beedrill
15                                       NULL
16               017, 018, Pidgeotto, Pidgeot
17                               018, Pidgeot
18                                       NULL
19                              020, Raticate
20                                       NULL
21                                022, Fearow
22                                       NULL
23                                 024, Arbok
24                                       NULL
25                                026, Raichu
26                                       NULL
27                             028, Sandslash
28                                       NULL
29              030, 031, Nidorina, Nidoqueen
30                             031, Nidoqueen
31                                       NULL
32               033, 034, Nidorino, Nidoking
33                              034, Nidoking
34                                       NULL
35                              036, Clefable
36                                       NULL
37                             038, Ninetales
38                                       NULL
39                            040, Wigglytuff
40                                       NULL
41                                042, Golbat
42                                       NULL
43                 044, 045, Gloom, Vileplume
44                             045, Vileplume
45                                       NULL
46                              047, Parasect
47                                       NULL
48                              049, Venomoth
49                                       NULL
50                               051, Dugtrio
51                                       NULL
52                               053, Persian
53                                       NULL
54                               055, Golduck
55                                       NULL
56                              057, Primeape
57                                       NULL
58                              059, Arcanine
59                                       NULL
60             061, 062, Poliwhirl, Poliwrath
61                             062, Poliwrath
62                                       NULL
63                064, 065, Kadabra, Alakazam
64                              065, Alakazam
65                                       NULL
66                 067, 068, Machoke, Machamp
67                               068, Machamp
68                                       NULL
69           070, 071, Weepinbell, Victreebel
70                            071, Victreebel
71                                       NULL
72                            073, Tentacruel
73                                       NULL
74                  075, 076, Graveler, Golem
75                                 076, Golem
76                                       NULL
77                              078, Rapidash
78                                       NULL
79                               080, Slowbro
80                                       NULL
81                              082, Magneton
82                                       NULL
83                                       NULL
84                                085, Dodrio
85                                       NULL
86                               087, Dewgong
87                                       NULL
88                                   089, Muk
89                                       NULL
90                              091, Cloyster
91                                       NULL
92                  093, 094, Haunter, Gengar
93                                094, Gengar
94                                       NULL
95                                       NULL
96                                 097, Hypno
97                                       NULL
98                               099, Kingler
99                                       NULL
100                            101, Electrode
101                                      NULL
102                            103, Exeggutor
103                                      NULL
104                              105, Marowak
105                                      NULL
106                                      NULL
107                                      NULL
108                                      NULL
109                              110, Weezing
110                                      NULL
111                               112, Rhydon
112                                      NULL
113                                      NULL
114                                      NULL
115                                      NULL
116                               117, Seadra
117                                      NULL
118                              119, Seaking
119                                      NULL
120                              121, Starmie
121                                      NULL
122                                      NULL
123                                      NULL
124                                      NULL
125                                      NULL
126                                      NULL
127                                      NULL
128                                      NULL
129                             130, Gyarados
130                                      NULL
131                                      NULL
132                                      NULL
133 134, 135, 136, Vaporeon, Jolteon, Flareon
134                                      NULL
135                                      NULL
136                                      NULL
137                                      NULL
138                              139, Omastar
139                                      NULL
140                             141, Kabutops
141                                      NULL
142                                      NULL
143                                      NULL
144                                      NULL
145                                      NULL
146                                      NULL
147            148, 149, Dragonair, Dragonite
148                            149, Dragonite
149                                      NULL
150                                      NULL
151                                      NULL
                         prev_evolution
1                                  NULL
2                        001, Bulbasaur
3          001, 002, Bulbasaur, Ivysaur
4                                  NULL
5                       004, Charmander
6      004, 005, Charmander, Charmeleon
7                                  NULL
8                         007, Squirtle
9         007, 008, Squirtle, Wartortle
10                                 NULL
11                        010, Caterpie
12          010, 011, Caterpie, Metapod
13                                 NULL
14                          013, Weedle
15             013, 014, Weedle, Kakuna
16                                 NULL
17                          016, Pidgey
18          016, 017, Pidgey, Pidgeotto
19                                 NULL
20                         019, Rattata
21                                 NULL
22                         021, Spearow
23                                 NULL
24                           023, Ekans
25                                 NULL
26                         025, Pikachu
27                                 NULL
28                       027, Sandshrew
29                                 NULL
30                 029, Nidoran(Female)
31  029, 030, Nidoran(Female), Nidorina
32                                 NULL
33                   032, Nidoran(Male)
34    032, 033, Nidoran(Male), Nidorino
35                                 NULL
36                        035, Clefairy
37                                 NULL
38                          037, Vulpix
39                                 NULL
40                      039, Jigglypuff
41                                 NULL
42                           041, Zubat
43                                 NULL
44                          043, Oddish
45              043, 044, Oddish, Gloom
46                                 NULL
47                           046, Paras
48                                 NULL
49                         048, Venonat
50                                 NULL
51                         050, Diglett
52                                 NULL
53                          052, Meowth
54                                 NULL
55                         054, Psyduck
56                                 NULL
57                          056, Mankey
58                                 NULL
59                       058, Growlithe
60                                 NULL
61                         060, Poliwag
62         060, 061, Poliwag, Poliwhirl
63                                 NULL
64                            063, Abra
65              063, 064, Abra, Kadabra
66                                 NULL
67                          066, Machop
68            066, 067, Machop, Machoke
69                                 NULL
70                      069, Bellsprout
71     069, 070, Bellsprout, Weepinbell
72                                 NULL
73                       072, Tentacool
74                                 NULL
75                         074, Geodude
76          074, 075, Geodude, Graveler
77                                 NULL
78                          077, Ponyta
79                                 NULL
80                        079, Slowpoke
81                                 NULL
82                       081, Magnemite
83                                 NULL
84                                 NULL
85                           084, Doduo
86                                 NULL
87                            086, Seel
88                                 NULL
89                          088, Grimer
90                                 NULL
91                        090, Shellder
92                                 NULL
93                          092, Gastly
94            092, 093, Gastly, Haunter
95                                 NULL
96                                 NULL
97                         096, Drowzee
98                                 NULL
99                          098, Krabby
100                                NULL
101                        100, Voltorb
102                                NULL
103                      102, Exeggcute
104                                NULL
105                         104, Cubone
106                                NULL
107                                NULL
108                                NULL
109                                NULL
110                        109, Koffing
111                                NULL
112                        111, Rhyhorn
113                                NULL
114                                NULL
115                                NULL
116                                NULL
117                         116, Horsea
118                                NULL
119                        118, Goldeen
120                                NULL
121                         120, Staryu
122                                NULL
123                                NULL
124                                NULL
125                                NULL
126                                NULL
127                                NULL
128                                NULL
129                                NULL
130                       129, Magikarp
131                                NULL
132                                NULL
133                                NULL
134                          133, Eevee
135                          133, Eevee
136                          133, Eevee
137                                NULL
138                                NULL
139                        138, Omanyte
140                                NULL
141                         140, Kabuto
142                                NULL
143                                NULL
144                                NULL
145                                NULL
146                                NULL
147                                NULL
148                        147, Dratini
149        147, 148, Dratini, Dragonair
150                                NULL
151                                NULL

Data frame structure from JSON

dim(jsonData$pokemon)
[1] 151  17
class(jsonData$pokemon)
[1] "data.frame"
jsonData$pokemon %>% filter(type == "Fire") %>% select(!(img))
    id num       name type height   weight            candy candy_count
1    4 004 Charmander Fire 0.61 m   8.5 kg Charmander Candy          25
2    5 005 Charmeleon Fire 1.09 m  19.0 kg Charmander Candy         100
3   37 037     Vulpix Fire 0.61 m   9.9 kg     Vulpix Candy          50
4   38 038  Ninetales Fire 1.09 m  19.9 kg     Vulpix Candy          NA
5   58 058  Growlithe Fire 0.71 m  19.0 kg  Growlithe Candy          50
6   59 059   Arcanine Fire 1.91 m 155.0 kg  Growlithe Candy          NA
7   77 077     Ponyta Fire 0.99 m  30.0 kg     Ponyta Candy          50
8   78 078   Rapidash Fire 1.70 m  95.0 kg     Ponyta Candy          NA
9  126 126     Magmar Fire 1.30 m  44.5 kg             None          NA
10 136 136    Flareon Fire 0.89 m  25.0 kg      Eevee Candy          NA
           egg spawn_chance avg_spawns spawn_time multipliers
1         2 km       0.2530      25.30      08:45        1.65
2  Not in Eggs       0.0120       1.20      19:00        1.79
3         5 km       0.2200      22.00      13:43  2.74, 2.81
4  Not in Eggs       0.0077       0.77      01:32        NULL
5         5 km       0.9200      92.00      03:57  2.31, 2.36
6  Not in Eggs       0.0170       1.70      03:11        NULL
7         5 km       0.5100      51.00      02:50  1.48, 1.50
8  Not in Eggs       0.0110       1.10      04:00        NULL
9        10 km       0.1000      10.00      20:36        NULL
10 Not in Eggs       0.0170       1.70      07:02        NULL
            weaknesses                  next_evolution  prev_evolution
1  Water, Ground, Rock 005, 006, Charmeleon, Charizard            NULL
2  Water, Ground, Rock                  006, Charizard 004, Charmander
3  Water, Ground, Rock                  038, Ninetales            NULL
4  Water, Ground, Rock                            NULL     037, Vulpix
5  Water, Ground, Rock                   059, Arcanine            NULL
6  Water, Ground, Rock                            NULL  058, Growlithe
7  Water, Ground, Rock                   078, Rapidash            NULL
8  Water, Ground, Rock                            NULL     077, Ponyta
9  Water, Ground, Rock                            NULL            NULL
10 Water, Ground, Rock                            NULL      133, Eevee

Going deeper..

class(jsonData$pokemon$type) # Can be lists
[1] "list"
jsonData$pokemon$type
[[1]]
[1] "Grass"  "Poison"

[[2]]
[1] "Grass"  "Poison"

[[3]]
[1] "Grass"  "Poison"

[[4]]
[1] "Fire"

[[5]]
[1] "Fire"

[[6]]
[1] "Fire"   "Flying"

[[7]]
[1] "Water"

[[8]]
[1] "Water"

[[9]]
[1] "Water"

[[10]]
[1] "Bug"

[[11]]
[1] "Bug"

[[12]]
[1] "Bug"    "Flying"

[[13]]
[1] "Bug"    "Poison"

[[14]]
[1] "Bug"    "Poison"

[[15]]
[1] "Bug"    "Poison"

[[16]]
[1] "Normal" "Flying"

[[17]]
[1] "Normal" "Flying"

[[18]]
[1] "Normal" "Flying"

[[19]]
[1] "Normal"

[[20]]
[1] "Normal"

[[21]]
[1] "Normal" "Flying"

[[22]]
[1] "Normal" "Flying"

[[23]]
[1] "Poison"

[[24]]
[1] "Poison"

[[25]]
[1] "Electric"

[[26]]
[1] "Electric"

[[27]]
[1] "Ground"

[[28]]
[1] "Ground"

[[29]]
[1] "Poison"

[[30]]
[1] "Poison"

[[31]]
[1] "Poison" "Ground"

[[32]]
[1] "Poison"

[[33]]
[1] "Poison"

[[34]]
[1] "Poison" "Ground"

[[35]]
[1] "Normal"

[[36]]
[1] "Normal"

[[37]]
[1] "Fire"

[[38]]
[1] "Fire"

[[39]]
[1] "Normal"

[[40]]
[1] "Normal"

[[41]]
[1] "Poison" "Flying"

[[42]]
[1] "Poison" "Flying"

[[43]]
[1] "Grass"  "Poison"

[[44]]
[1] "Grass"  "Poison"

[[45]]
[1] "Grass"  "Poison"

[[46]]
[1] "Bug"   "Grass"

[[47]]
[1] "Bug"   "Grass"

[[48]]
[1] "Bug"    "Poison"

[[49]]
[1] "Bug"    "Poison"

[[50]]
[1] "Ground"

[[51]]
[1] "Ground"

[[52]]
[1] "Normal"

[[53]]
[1] "Normal"

[[54]]
[1] "Water"

[[55]]
[1] "Water"

[[56]]
[1] "Fighting"

[[57]]
[1] "Fighting"

[[58]]
[1] "Fire"

[[59]]
[1] "Fire"

[[60]]
[1] "Water"

[[61]]
[1] "Water"

[[62]]
[1] "Water"    "Fighting"

[[63]]
[1] "Psychic"

[[64]]
[1] "Psychic"

[[65]]
[1] "Psychic"

[[66]]
[1] "Fighting"

[[67]]
[1] "Fighting"

[[68]]
[1] "Fighting"

[[69]]
[1] "Grass"  "Poison"

[[70]]
[1] "Grass"  "Poison"

[[71]]
[1] "Grass"  "Poison"

[[72]]
[1] "Water"  "Poison"

[[73]]
[1] "Water"  "Poison"

[[74]]
[1] "Rock"   "Ground"

[[75]]
[1] "Rock"   "Ground"

[[76]]
[1] "Rock"   "Ground"

[[77]]
[1] "Fire"

[[78]]
[1] "Fire"

[[79]]
[1] "Water"   "Psychic"

[[80]]
[1] "Water"   "Psychic"

[[81]]
[1] "Electric"

[[82]]
[1] "Electric"

[[83]]
[1] "Normal" "Flying"

[[84]]
[1] "Normal" "Flying"

[[85]]
[1] "Normal" "Flying"

[[86]]
[1] "Water"

[[87]]
[1] "Water" "Ice"  

[[88]]
[1] "Poison"

[[89]]
[1] "Poison"

[[90]]
[1] "Water"

[[91]]
[1] "Water" "Ice"  

[[92]]
[1] "Ghost"  "Poison"

[[93]]
[1] "Ghost"  "Poison"

[[94]]
[1] "Ghost"  "Poison"

[[95]]
[1] "Rock"   "Ground"

[[96]]
[1] "Psychic"

[[97]]
[1] "Psychic"

[[98]]
[1] "Water"

[[99]]
[1] "Water"

[[100]]
[1] "Electric"

[[101]]
[1] "Electric"

[[102]]
[1] "Grass"   "Psychic"

[[103]]
[1] "Grass"   "Psychic"

[[104]]
[1] "Ground"

[[105]]
[1] "Ground"

[[106]]
[1] "Fighting"

[[107]]
[1] "Fighting"

[[108]]
[1] "Normal"

[[109]]
[1] "Poison"

[[110]]
[1] "Poison"

[[111]]
[1] "Ground" "Rock"  

[[112]]
[1] "Ground" "Rock"  

[[113]]
[1] "Normal"

[[114]]
[1] "Grass"

[[115]]
[1] "Normal"

[[116]]
[1] "Water"

[[117]]
[1] "Water"

[[118]]
[1] "Water"

[[119]]
[1] "Water"

[[120]]
[1] "Water"

[[121]]
[1] "Water"   "Psychic"

[[122]]
[1] "Psychic"

[[123]]
[1] "Bug"    "Flying"

[[124]]
[1] "Ice"     "Psychic"

[[125]]
[1] "Electric"

[[126]]
[1] "Fire"

[[127]]
[1] "Bug"

[[128]]
[1] "Normal"

[[129]]
[1] "Water"

[[130]]
[1] "Water"  "Flying"

[[131]]
[1] "Water" "Ice"  

[[132]]
[1] "Normal"

[[133]]
[1] "Normal"

[[134]]
[1] "Water"

[[135]]
[1] "Electric"

[[136]]
[1] "Fire"

[[137]]
[1] "Normal"

[[138]]
[1] "Rock"  "Water"

[[139]]
[1] "Rock"  "Water"

[[140]]
[1] "Rock"  "Water"

[[141]]
[1] "Rock"  "Water"

[[142]]
[1] "Rock"   "Flying"

[[143]]
[1] "Normal"

[[144]]
[1] "Ice"    "Flying"

[[145]]
[1] "Electric" "Flying"  

[[146]]
[1] "Fire"   "Flying"

[[147]]
[1] "Dragon"

[[148]]
[1] "Dragon"

[[149]]
[1] "Dragon" "Flying"

[[150]]
[1] "Psychic"

[[151]]
[1] "Psychic"

Data frame structure from JSON

class(jsonData$pokemon$next_evolution[[1]]) # Or lists of data.frames!
[1] "data.frame"
jsonData$pokemon$next_evolution
[[1]]
  num     name
1 002  Ivysaur
2 003 Venusaur

[[2]]
  num     name
1 003 Venusaur

[[3]]
NULL

[[4]]
  num       name
1 005 Charmeleon
2 006  Charizard

[[5]]
  num      name
1 006 Charizard

[[6]]
NULL

[[7]]
  num      name
1 008 Wartortle
2 009 Blastoise

[[8]]
  num      name
1 009 Blastoise

[[9]]
NULL

[[10]]
  num       name
1 011    Metapod
2 012 Butterfree

[[11]]
  num       name
1 012 Butterfree

[[12]]
NULL

[[13]]
  num     name
1 014   Kakuna
2 015 Beedrill

[[14]]
  num     name
1 015 Beedrill

[[15]]
NULL

[[16]]
  num      name
1 017 Pidgeotto
2 018   Pidgeot

[[17]]
  num    name
1 018 Pidgeot

[[18]]
NULL

[[19]]
  num     name
1 020 Raticate

[[20]]
NULL

[[21]]
  num   name
1 022 Fearow

[[22]]
NULL

[[23]]
  num  name
1 024 Arbok

[[24]]
NULL

[[25]]
  num   name
1 026 Raichu

[[26]]
NULL

[[27]]
  num      name
1 028 Sandslash

[[28]]
NULL

[[29]]
  num      name
1 030  Nidorina
2 031 Nidoqueen

[[30]]
  num      name
1 031 Nidoqueen

[[31]]
NULL

[[32]]
  num     name
1 033 Nidorino
2 034 Nidoking

[[33]]
  num     name
1 034 Nidoking

[[34]]
NULL

[[35]]
  num     name
1 036 Clefable

[[36]]
NULL

[[37]]
  num      name
1 038 Ninetales

[[38]]
NULL

[[39]]
  num       name
1 040 Wigglytuff

[[40]]
NULL

[[41]]
  num   name
1 042 Golbat

[[42]]
NULL

[[43]]
  num      name
1 044     Gloom
2 045 Vileplume

[[44]]
  num      name
1 045 Vileplume

[[45]]
NULL

[[46]]
  num     name
1 047 Parasect

[[47]]
NULL

[[48]]
  num     name
1 049 Venomoth

[[49]]
NULL

[[50]]
  num    name
1 051 Dugtrio

[[51]]
NULL

[[52]]
  num    name
1 053 Persian

[[53]]
NULL

[[54]]
  num    name
1 055 Golduck

[[55]]
NULL

[[56]]
  num     name
1 057 Primeape

[[57]]
NULL

[[58]]
  num     name
1 059 Arcanine

[[59]]
NULL

[[60]]
  num      name
1 061 Poliwhirl
2 062 Poliwrath

[[61]]
  num      name
1 062 Poliwrath

[[62]]
NULL

[[63]]
  num     name
1 064  Kadabra
2 065 Alakazam

[[64]]
  num     name
1 065 Alakazam

[[65]]
NULL

[[66]]
  num    name
1 067 Machoke
2 068 Machamp

[[67]]
  num    name
1 068 Machamp

[[68]]
NULL

[[69]]
  num       name
1 070 Weepinbell
2 071 Victreebel

[[70]]
  num       name
1 071 Victreebel

[[71]]
NULL

[[72]]
  num       name
1 073 Tentacruel

[[73]]
NULL

[[74]]
  num     name
1 075 Graveler
2 076    Golem

[[75]]
  num  name
1 076 Golem

[[76]]
NULL

[[77]]
  num     name
1 078 Rapidash

[[78]]
NULL

[[79]]
  num    name
1 080 Slowbro

[[80]]
NULL

[[81]]
  num     name
1 082 Magneton

[[82]]
NULL

[[83]]
NULL

[[84]]
  num   name
1 085 Dodrio

[[85]]
NULL

[[86]]
  num    name
1 087 Dewgong

[[87]]
NULL

[[88]]
  num name
1 089  Muk

[[89]]
NULL

[[90]]
  num     name
1 091 Cloyster

[[91]]
NULL

[[92]]
  num    name
1 093 Haunter
2 094  Gengar

[[93]]
  num   name
1 094 Gengar

[[94]]
NULL

[[95]]
NULL

[[96]]
  num  name
1 097 Hypno

[[97]]
NULL

[[98]]
  num    name
1 099 Kingler

[[99]]
NULL

[[100]]
  num      name
1 101 Electrode

[[101]]
NULL

[[102]]
  num      name
1 103 Exeggutor

[[103]]
NULL

[[104]]
  num    name
1 105 Marowak

[[105]]
NULL

[[106]]
NULL

[[107]]
NULL

[[108]]
NULL

[[109]]
  num    name
1 110 Weezing

[[110]]
NULL

[[111]]
  num   name
1 112 Rhydon

[[112]]
NULL

[[113]]
NULL

[[114]]
NULL

[[115]]
NULL

[[116]]
  num   name
1 117 Seadra

[[117]]
NULL

[[118]]
  num    name
1 119 Seaking

[[119]]
NULL

[[120]]
  num    name
1 121 Starmie

[[121]]
NULL

[[122]]
NULL

[[123]]
NULL

[[124]]
NULL

[[125]]
NULL

[[126]]
NULL

[[127]]
NULL

[[128]]
NULL

[[129]]
  num     name
1 130 Gyarados

[[130]]
NULL

[[131]]
NULL

[[132]]
NULL

[[133]]
  num     name
1 134 Vaporeon
2 135  Jolteon
3 136  Flareon

[[134]]
NULL

[[135]]
NULL

[[136]]
NULL

[[137]]
NULL

[[138]]
  num    name
1 139 Omastar

[[139]]
NULL

[[140]]
  num     name
1 141 Kabutops

[[141]]
NULL

[[142]]
NULL

[[143]]
NULL

[[144]]
NULL

[[145]]
NULL

[[146]]
NULL

[[147]]
  num      name
1 148 Dragonair
2 149 Dragonite

[[148]]
  num      name
1 149 Dragonite

[[149]]
NULL

[[150]]
NULL

[[151]]
NULL

Lab

Extra Slides: Web Scraping and APIs

This is data

View the source

What the computer sees

Ways to see the source

Inspect element

Copy XPath

Use SelectorGadget

rvest package

recount_url <- "http://bowtie-bio.sourceforge.net/recount/"
# install.packages("rvest")
library(rvest)
htmlfile <- read_html(recount_url)

nds <- html_nodes(htmlfile, xpath = '//*[@id="recounttab"]/table')
dat <- html_table(nds)
dat <- as.data.frame(dat)
head(dat)
       X1                                         X2      X3
1   Study                                       PMID Species
2 bodymap not published, but publicly available here   human
3  cheung                                   20856902   human
4    core                                   19056941   human
5   gilad                                   20009012   human
6    maqc                                   20167110   human
                                X4                               X5
1  Number of biological replicates Number of uniquely aligned reads
2                               19                    2,197,622,796
3                               41                      834,584,950
4                                2                        8,670,342
5                                6                       41,356,738
6 14 (technical)**  2 (biological)                       71,970,164
               X6              X7              X8
1   ExpressionSet     Count table Phenotype table
2            link            link            link
3            link            link            link
4            link            link            link
5            link            link            link
6 original pooled original pooled original pooled
                                               X9
1                                           Notes
2 Illumina Human BodyMap 2.0 -- tissue comparison
3                                    HapMap - CEU
4                                lung fibroblasts
5                        liver; males and femlaes
6                              experiment: MAQC-2

Little cleanup

colnames(dat) <- as.character(dat[1,])
dat <- dat[-1,]
head(dat)
       Study                                       PMID Species
2    bodymap not published, but publicly available here   human
3     cheung                                   20856902   human
4       core                                   19056941   human
5      gilad                                   20009012   human
6       maqc                                   20167110   human
7 montgomery                                   20220756   human
   Number of biological replicates Number of uniquely aligned reads
2                               19                    2,197,622,796
3                               41                      834,584,950
4                                2                        8,670,342
5                                6                       41,356,738
6 14 (technical)**  2 (biological)                       71,970,164
7                               60                     *886,468,054
    ExpressionSet     Count table Phenotype table
2            link            link            link
3            link            link            link
4            link            link            link
5            link            link            link
6 original pooled original pooled original pooled
7            link            link            link
                                            Notes
2 Illumina Human BodyMap 2.0 -- tissue comparison
3                                    HapMap - CEU
4                                lung fibroblasts
5                        liver; males and femlaes
6                              experiment: MAQC-2
7                                    HapMap - CEU

Ethics and Web Scraping

Ethics and Web Scraping

Ethics and Web Scraping

Ethics and Web Scraping

APIs

Application Programming Interfaces

In biology too!

Step 0: Did someone do this already

Step 0: Did someone do this already

Step 1: DIY

https://github.com/ThatCopy/catAPI/wiki/Usage

#install.packages("httr")
library(httr)

# Requests a random cat fact
query_url <- "https://catfact.ninja/fact"

req <- GET(query_url)
content(req)
$fact
[1] "Phoenician cargo ships are thought to have brought the first domesticated cats to Europe in about 900 BC."

$length
[1] 105

Not all APIs are “open”