Skip to content

Instantly share code, notes, and snippets.

@clauswilke
Last active February 17, 2018 05:58
Show Gist options
  • Save clauswilke/c621c27d88c012ba61eb7bd90d1399f9 to your computer and use it in GitHub Desktop.
Save clauswilke/c621c27d88c012ba61eb7bd90d1399f9 to your computer and use it in GitHub Desktop.
Internet users over time; plot variations
country year users
Argentina 1994 0.043705951
Brazil 1994 0.037672709
Canada 1994 2.378693853
Chile 1994 0.141084507
China 1994 0.001168115
Germany 1994 0.922541043
Algeria 1994 0.000360674
France 1994 0.899867425
United Kingdom 1994 1.036609166
India 1994 0.001069562
Iceland 1994 6.794811784
Israel 1994 0.57696646
Italy 1994 0.192304619
Japan 1994 0.799684291
Kenya 1994 0
Mexico 1994 0.043339167
Norway 1994 4.152450292
New Zealand 1994 3.168718848
United States 1994 4.862780635
South Africa 1994 0.246905533
Argentina 1995 0.086277081
Brazil 1995 0.105138168
Canada 1995 4.163525253
Chile 1995 0.346980781
China 1995 0.00495471
Germany 1995 1.837737754
Algeria 1995 0.001768954
France 1995 1.637947245
United Kingdom 1995 1.895168284
India 1995 0.026228879
Iceland 1995 11.2158757
Israel 1995 0.93042297
Italy 1995 0.524412787
Japan 1995 1.594363148
Kenya 1995 0.000727482
Mexico 1995 0.10256419
Norway 1995 6.423220493
New Zealand 1995 4.88424078
United States 1995 9.237088297
South Africa 1995 0.676740104
Argentina 1996 0.141954704
Brazil 1996 0.450789179
Canada 1996 6.76023965
Chile 1996 0.68347561
China 1996 0.013081692
Germany 1996 3.054805234
Algeria 1996 0.001738533
France 1996 2.584033979
United Kingdom 1996 4.123650336
India 1996 0.046333977
Iceland 1996 14.80647932
Israel 1996 2.1683676
Italy 1996 1.023289903
Japan 1996 4.372981968
Kenya 1996 0.008839115
Mexico 1996 0.20040628
Norway 1996 18.25031077
New Zealand 1996 8.041899368
United States 1996 16.41935296
South Africa 1996 0.841882931
Argentina 1997 0.280339882
Brazil 1997 0.786079155
Canada 1997 15.07235736
Chile 1997 1.057092496
China 1997 0.032394861
Germany 1997 6.711087477
Algeria 1997 0.010268463
France 1997 4.255003872
United Kingdom 1997 7.385398957
India 1997 0.070767849
Iceland 1997 27.47886875
Israel 1997 4.399405482
Italy 1997 2.276737834
Japan 1997 9.16307714
Kenya 1997 0.034406051
Mexico 1997 0.62731154
Norway 1997 20.41788144
New Zealand 1997 14.6015244
United States 1997 21.61640097
South Africa 1997 1.632093791
Argentina 1998 0.83076668
Brazil 1998 1.477874959
Canada 1998 24.8974003
Chile 1998 1.662322022
China 1998 0.168540297
Germany 1998 9.877852428
Algeria 1998 0.020238555
France 1998 6.319778722
United Kingdom 1998 13.6699831
India 1998 0.139027329
Iceland 1998 36.2642065
Israel 1998 10.30706995
Italy 1998 4.558519565
Japan 1998 13.41404088
Kenya 1998 0.050261388
Mexico 1998 1.265783278
Norway 1998 22.56011255
New Zealand 1998 31.63626081
United States 1998 30.09319659
South Africa 1998 2.906220867
Argentina 1999 3.284481956
Brazil 1999 2.038732184
Canada 1999 36.18644004
Chile 1999 4.103419297
China 1999 0.708187957
Germany 1999 20.84598264
Algeria 1999 0.199523843
France 1999 9.125317889
United Kingdom 1999 21.29363827
India 1999 0.273224277
Iceland 1999 41.29456671
Israel 1999 13.43612191
Italy 1999 14.37841019
Japan 1999 21.39129031
Kenya 1999 0.114256028
Mexico 1999 1.857436221
Norway 1999 40
New Zealand 1999 41.49448266
United States 1999 35.84872446
South Africa 1999 4.116249583
Argentina 2000 7.038683086
Brazil 2000 2.870685159
Canada 2000 51.3
Chile 2000 16.6
China 2000 1.775913207
Germany 2000 30.2163466
Algeria 2000 0.491705679
France 2000 14.30792394
United Kingdom 2000 26.82175435
India 2000 0.52753245
Iceland 2000 44.47053382
Israel 2000 20.87379
Italy 2000 23.11087424
Japan 2000 29.99074036
Kenya 2000 0.318059714
Mexico 2000 5.081384153
Norway 2000 52
New Zealand 2000 47.37955654
United States 2000 43.07916264
South Africa 2000 5.348559732
Argentina 2001 9.780807285
Brazil 2001 4.528494869
Canada 2001 60.2
Chile 2001 19.1
China 2001 2.639650215
Germany 2001 31.65093942
Algeria 2001 0.646114017
France 2001 26.32590355
United Kingdom 2001 33.48109487
India 2001 0.660146377
Iceland 2001 49.39299537
Israel 2001 17.37862386
Italy 2001 27.22211698
Japan 2001 38.53206086
Kenya 2001 0.619782266
Mexico 2001 7.038023117
Norway 2001 64
New Zealand 2001 53.24101529
United States 2001 49.08083159
South Africa 2001 6.346619318
Argentina 2002 10.88212438
Brazil 2002 9.149425086
Canada 2002 61.59329927
Chile 2002 22.1
China 2002 4.595704331
Germany 2002 48.82
Algeria 2002 1.59164126
France 2002 30.18
United Kingdom 2002 56.48
India 2002 1.537875582
Iceland 2002 79.12
Israel 2002 17.76459906
Italy 2002 28.04
Japan 2002 46.59420112
Kenya 2002 1.207773885
Mexico 2002 11.9
Norway 2002 72.84
New Zealand 2002 59.08075328
United States 2002 58.78540388
South Africa 2002 6.710322437
Argentina 2003 11.91369655
Brazil 2003 13.2075861
Canada 2003 64.2
Chile 2003 25.47377889
China 2003 6.2
Germany 2003 55.9
Algeria 2003 2.195359731
France 2003 36.14
United Kingdom 2003 64.82
India 2003 1.686489971
Iceland 2003 83.14
Israel 2003 19.59339366
Italy 2003 29.04
Japan 2003 48.43526589
Kenya 2003 2.941902861
Mexico 2003 12.9
Norway 2003 78.13
New Zealand 2003 60.96253987
United States 2003 61.69711712
South Africa 2003 7.007691726
Argentina 2004 16.03668411
Brazil 2004 19.07367227
Canada 2004 65.95596346
Chile 2004 28.17791012
China 2004 7.3
Germany 2004 64.73
Algeria 2004 4.634475088
France 2004 39.15
United Kingdom 2004 65.61
India 2004 1.976136492
Iceland 2004 83.88
Israel 2004 22.77048553
Italy 2004 33.24
Japan 2004 62.39392963
Kenya 2004 3.023528042
Mexico 2004 14.1
Norway 2004 77.69
New Zealand 2004 61.84762781
United States 2004 64.75825648
South Africa 2004 8.425118683
Argentina 2005 17.72058337
Brazil 2005 21.02274725
Canada 2005 71.66
Chile 2005 31.17534703
China 2005 8.523257003
Germany 2005 68.71
Algeria 2005 5.843942092
France 2005 42.87
United Kingdom 2005 70
India 2005 2.388075
Iceland 2005 87
Israel 2005 25.19404242
Italy 2005 35
Japan 2005 66.9210661
Kenya 2005 3.101897702
Mexico 2005 17.21
Norway 2005 81.99
New Zealand 2005 62.72021237
United States 2005 67.96805292
South Africa 2005 7.48854253
Argentina 2006 20.9272021
Brazil 2006 28.17838018
Canada 2006 72.4
Chile 2006 34.49775117
China 2006 10.52315262
Germany 2006 72.16
Algeria 2006 7.375984956
France 2006 46.87
United Kingdom 2006 68.82
India 2006 2.805499865
Iceland 2006 89.51
Israel 2006 27.88107446
Italy 2006 37.99
Japan 2006 68.68527032
Kenya 2006 3.6
Mexico 2006 19.52
Norway 2006 82.55
New Zealand 2006 69
United States 2006 68.93119327
South Africa 2006 7.607139675
Argentina 2007 25.94663294
Brazil 2007 30.88
Canada 2007 73.2
Chile 2007 35.9
China 2007 16
Germany 2007 75.16
Algeria 2007 9.451190626
France 2007 66.09
United Kingdom 2007 75.09
India 2007 3.95
Iceland 2007 90.6
Israel 2007 48.12806219
Italy 2007 40.79
Japan 2007 74.3
Kenya 2007 4.4
Mexico 2007 20.81
Norway 2007 86.93
New Zealand 2007 69.76
United States 2007 75
South Africa 2007 8.065375174
Argentina 2008 28.11262348
Brazil 2008 33.83
Canada 2008 76.7
Chile 2008 37.3
China 2008 22.6
Germany 2008 78
Algeria 2008 10.18
France 2008 70.68
United Kingdom 2008 78.39
India 2008 4.38
Iceland 2008 91
Israel 2008 59.39
Italy 2008 44.53
Japan 2008 75.4
Kenya 2008 5.2
Mexico 2008 21.71
Norway 2008 90.57
New Zealand 2008 72.03
United States 2008 74
South Africa 2008 8.43
Argentina 2009 34
Brazil 2009 39.22
Canada 2009 80.3
Chile 2009 41.56
China 2009 28.9
Germany 2009 79
Algeria 2009 11.23
France 2009 71.58
United Kingdom 2009 83.56
India 2009 5.12
Iceland 2009 93
Israel 2009 63.12
Italy 2009 48.83
Japan 2009 78
Kenya 2009 6.1
Mexico 2009 26.34
Norway 2009 92.08
New Zealand 2009 79.7
United States 2009 71
South Africa 2009 10
Argentina 2010 45
Brazil 2010 40.65
Canada 2010 80.3
Chile 2010 45
China 2010 34.3
Germany 2010 82
Algeria 2010 12.5
France 2010 77.28
United Kingdom 2010 85
India 2010 7.5
Iceland 2010 93.39
Israel 2010 67.5
Italy 2010 53.68
Japan 2010 78.21
Kenya 2010 7.2
Mexico 2010 31.05
Norway 2010 93.39
New Zealand 2010 80.46
United States 2010 71.69
South Africa 2010 24
Argentina 2011 51
Brazil 2011 45.69
Canada 2011 83
Chile 2011 52.24960729
China 2011 38.3
Germany 2011 81.26999954
Algeria 2011 14.9
France 2011 77.81999899
United Kingdom 2011 85.37999855
India 2011 10.07
Iceland 2011 94.8196868
Israel 2011 68.87387799
Italy 2011 54.3899983
Japan 2011 79.05411352
Kenya 2011 8.8
Mexico 2011 37.17629541
Norway 2011 93.48998265
New Zealand 2011 81.23
United States 2011 69.72946076
South Africa 2011 33.97
Argentina 2012 55.8
Brazil 2012 48.56
Canada 2012 83
Chile 2012 55.05
China 2012 42.30011749
Germany 2012 82.34999847
Algeria 2012 18.2
France 2012 81.44
United Kingdom 2012 87.47999842
India 2012 12.58006091
Iceland 2012 96.20979955
Israel 2012 70.8
Italy 2012 55.82999799
Japan 2012 79.4964
Kenya 2012 10.5
Mexico 2012 39.75
Norway 2012 94.64997805
New Zealand 2012 81.64447018
United States 2012 74.7
South Africa 2012 41
Argentina 2013 59.9
Brazil 2013 51.04
Canada 2013 85.8
Chile 2013 58
China 2013 45.8
Germany 2013 84.17
Algeria 2013 22.5
France 2013 81.9198
United Kingdom 2013 89.8441
India 2013 15.1
Iceland 2013 96.5468
Israel 2013 70.25031195
Italy 2013 58.4593
Japan 2013 88.21942891
Kenya 2013 13
Mexico 2013 43.46
Norway 2013 95.0534
New Zealand 2013 82.78
United States 2013 71.4
South Africa 2013 46.5
Argentina 2014 64.7
Brazil 2014 54.55100188
Canada 2014 87.12
Chile 2014 61.11
China 2014 47.9
Germany 2014 86.19
Algeria 2014 29.5
France 2014 83.75
United Kingdom 2014 91.61
India 2014 21
Iceland 2014 98.16
Israel 2014 75.01775316
Italy 2014 55.63846022
Japan 2014 89.10683302
Kenya 2014 16.5
Mexico 2014 44.39
Norway 2014 96.3
New Zealand 2014 85.5
United States 2014 73
South Africa 2014 49
Argentina 2015 68.04306411
Brazil 2015 58.32795173
Canada 2015 88.47
Chile 2015 64.289
China 2015 50.3
Germany 2015 87.5898
Algeria 2015 38.2
France 2015 84.6945
United Kingdom 2015 92.0003
India 2015 26
Iceland 2015 98.2
Israel 2015 77.35208966
Italy 2015 58.14173496
Japan 2015 91.05802839
Kenya 2015 21
Mexico 2015 57.43104299
Norway 2015 96.8103
New Zealand 2015 88.22288882
United States 2015 74.55420245
South Africa 2015 51.91911572
Argentina 2016 70.15076431
Brazil 2016 59.68274736
Canada 2016 89.84
Chile 2016 66.01
China 2016 53.2
Germany 2016 89.64710059
Algeria 2016 42.94552688
France 2016 85.62219995
United Kingdom 2016 94.77580063
India 2016 29.54716289
Iceland 2016 98.2400163
Israel 2016 79.77879126
Italy 2016 61.32425277
Japan 2016 92
Kenya 2016 26
Mexico 2016 59.540446
Norway 2016 97.29820367
New Zealand 2016 88.47018635
United States 2016 76.17673698
South Africa 2016 54
library(tidyverse) # code uses development version of ggplot2 for viridis scales; otherwise, viridis package would be needed
df_internet <- read.csv("internet.csv")
# sort countries by internet users in final year
internet_summary <- df_internet %>%
group_by(country) %>%
summarize(last = users[n()]) %>%
arrange(last)
df_internet <- mutate(df_internet, country = factor(country, levels = internet_summary$country))
# heatmap
ggplot(df_internet, aes(x = year, y = country, fill = users)) +
geom_tile(color = "white", size = 0.25) +
scale_fill_viridis_c(option = "A")
# line plot
ggplot(df_internet, aes(x = year, y = users, color = country)) +
geom_line() +
scale_color_viridis_d(option = "A")
# side-by-side boxplots
ggplot(df_internet, aes(x = year, y = users, group = year)) +
geom_boxplot()
# bar plot of current internet usage
ggplot(filter(df_internet, year == 2016), aes(x = country, y = users)) +
geom_col() + coord_flip()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment