Skip to content

Instantly share code, notes, and snippets.

View kanishkamisra's full-sized avatar
😶‍🌫️

Kanishka kanishkamisra

😶‍🌫️
View GitHub Profile
@kanishkamisra
kanishkamisra / lobstr_dplyr.R
Created August 26, 2018 21:23
tracemem experiment for dplyr
library(lobstr)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
@kanishkamisra
kanishkamisra / week10_tidying.R
Created June 5, 2018 02:22
TidyTuesday Week10 data fix script
library(tidyverse)
bikeshare <- dir(path = "PublicTripData/", pattern = "*.csv") %>%
map(~read.csv(file.path("PublicTripData", .))) %>%
reduce(bind_rows) %>%
as_tibble()
write_csv(bikeshare, "week10_biketown_tidy.csv")
library(tidyverse)
#> ── Attaching packages ─────────────────────────────────────────────────────────── tidyverse 1.2.1 ──
#> ✔ ggplot2 2.2.1 ✔ purrr 0.2.4
#> ✔ tibble 1.4.2 ✔ dplyr 0.7.4
#> ✔ tidyr 0.8.0 ✔ stringr 1.3.0
#> ✔ readr 1.1.1 ✔ forcats 0.2.0
#> ── Conflicts ────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
#> ✖ dplyr::filter() masks stats::filter()
#> ✖ dplyr::lag() masks stats::lag()
@kanishkamisra
kanishkamisra / region faceted plot.R
Created February 24, 2018 22:36
Code for r/dataisbeautiful monthly DataViz Battle thread - Feb 2018
library(tidyverse)
library(geofacet)
library(kani)
same_sex <- read_csv("https://raw.githubusercontent.com/zonination/samesmarriage/master/ssm.csv")
same_sex %>%
gather(`1995`:`2015`, key = "Year", value = "Law") %>%
mutate(
Year = as.numeric(Year),
@kanishkamisra
kanishkamisra / happiness_results.R
Created January 30, 2018 15:28
Happiness = sum of all columns (possibly)
library(tidyverse)
#> ── Attaching packages ─────────────────────────────────────────────────────────────────── tidyverse 1.2.1 ──
#> ✔ ggplot2 2.2.1.9000 ✔ purrr 0.2.4
#> ✔ tibble 1.4.2 ✔ dplyr 0.7.4
#> ✔ tidyr 0.7.2 ✔ stringr 1.2.0
#> ✔ readr 1.1.1 ✔ forcats 0.2.0
#> ── Conflicts ────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
#> ✖ dplyr::filter() masks stats::filter()
#> ✖ dplyr::lag() masks stats::lag()
library(janitor)
@kanishkamisra
kanishkamisra / usa_rate.csv
Created July 19, 2017 13:29
Mortality rates for all genders in the US, 1980-2014. Extracted from IHME
location_id location_name FIPS year_id mx lower upper
102 United States 0 1980 1113.75872590965 1112.14649814583 1115.39325540527
102 United States 0 1981 1093.80132885297 1092.51658901195 1095.10749694511
102 United States 0 1982 1071.56549903362 1070.30010778153 1072.75108714204
102 United States 0 1983 1068.21524898519 1067.09190059868 1069.33010095745
102 United States 0 1984 1063.27566678331 1062.22282670442 1064.40719514176
102 United States 0 1985 1064.32820287557 1063.21286711618 1065.46191626567
102 United States 0 1986 1058.0774400027 1056.93109112485 1059.22794331396
102 United States 0 1987 1051.01699221771 1049.9579599548 1052.13377899678
102 United States 0 1988 1048.06195271938 1046.85977624715 1049.1101161497
@kanishkamisra
kanishkamisra / state_mortality
Created July 19, 2017 13:26
State Mortality rates for all genders in USA States, 1980 - 2014. Extracted from IHME
"location_id","location_name","FIPS","year_id","mx","lower","upper"
523,"Alabama",1,1980,1164.63296101922,1157.59200189141,1171.69560107631
523,"Alabama",1,1981,1147.74970155969,1140.97226876081,1154.81589158437
523,"Alabama",1,1982,1125.71506390194,1118.83907922099,1133.0175651763
523,"Alabama",1,1983,1126.67975171529,1119.27693296457,1133.81562296821
523,"Alabama",1,1984,1130.39254293465,1123.69785221276,1137.31308486031
523,"Alabama",1,1985,1135.52946857505,1128.40961756764,1142.82743216841
523,"Alabama",1,1986,1133.35228269141,1126.61209847893,1139.72388933858
523,"Alabama",1,1987,1125.17118011652,1118.74809446048,1131.64293637908
523,"Alabama",1,1988,1133.39478461678,1126.62957479864,1140.49561807992
@kanishkamisra
kanishkamisra / issue_data.csv
Created July 12, 2017 02:54
Tweenr issue data
team game_number points cumm_points
Arsenal 1 0 0
Arsenal 2 1 1
Arsenal 3 3 4
Arsenal 4 3 7
Arsenal 5 3 10
Arsenal 6 3 13
Arsenal 7 3 16
Arsenal 8 3 19
Arsenal 9 1 20
x y group letter colors type .frame
10 80 1 h a one 1
10 70 1 a a one 1
10 70 1 p1 a one 1
10 70 1 p2 a one 1
10 80 1 y a one 1
10 70 1 b b one 1
15 70 1 i b one 1
10 70 1 r b one 1
15 70 1 t b one 1
@kanishkamisra
kanishkamisra / sea-ice-extent-months.R
Created June 28, 2017 14:33
Animated plot to rank the months with the most ice extents in the sea. 1979-2016
library(tidyverse)
library(lubridate)
library(extrafont)
library(kani)
library(directlabels)
library(gganimate)
library(scales)
library(tweenr)
sea_ice <- read.csv("https://raw.githubusercontent.com/kanishkamisra/sea-ice-extent/master/seaice.csv") %>% select(-Source.Data)