This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Helper Function | |
fn_downloadZip <- function(URL) { | |
myzip <- unz(URL, filename=basename(URL)) | |
c.zip.name = "test.zip" | |
c.file.path = file.path(c.home.dir,c.data.dir,c.zip.name) | |
c.data.folder = file.path(c.home.dir,c.data.dir) | |
download.file(URL, destfile=c.file.path) | |
f.name = unzip(c.file.path, exdir=c.data.folder) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hi, | |
----------------------------------- | |
PROBLEM STATEMENT | |
----------------------------------- | |
I want to generate URLS for each month for each year as follows: | |
[...] | |
https://s3.amazonaws.com/data/201611.csv.zip | |
https://s3.amazonaws.com/data/201612.csv.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## ````````````````````````````````````````````` | |
#### Read Me #### | |
## ````````````````````````````````````````````` | |
## Trying to implement "sessionization" in R | |
## Details here: | |
## https://www.dataiku.com/learn/guide/code/reshaping_data/sessionization.html | |
## ````````````````````````````````````````````` | |
## ````````````````````````````````````````````` | |
#### Load Libraries #### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: mit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Social Strata | Reason | Rate | |
---|---|---|---|
Rich people | good education, high qualification | 28% | |
Middle class | good education, high qualification | 33% | |
Poor | good education, high qualification | 18% | |
Rich people | cunning, cheating | 11% | |
Middle class | cunning, cheating | 21% | |
Poor | cunning, cheating | 32% | |
Rich people | abilities, talents | 13% | |
Middle class | abilities, talents | 8% | |
Poor | abilities, talents | 7% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------- | |
# HELPER FUNCTION | |
# ------------------- | |
# fn to search rank | |
# INPUT: year (integer) | |
# OUTPUT: rank (integer) | |
# SRC: | |
# http://adv-r.had.co.nz/Functions.html | |
# https://cran.r-project.org/web/packages/ArgumentCheck/vignettes/ArgumentChecking.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# list of all data frames | |
s.df = names(which(sapply(.GlobalEnv, is.data.frame))) | |
# list of data frames with .p. in their names | |
s.df.p = s.df[str_detect(s.df,regex("\\.p\\.",ignore_case = FALSE))] | |
# creating path | |
paths <- paste0(s.df.p,".1", ".csv") | |
# helper function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import sys | |
import random | |
from collections import deque | |
from PIL import Image | |
# THIS IS THE MAGIC VALUE THAT MAKES EVERYTHING GLITCHED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### Load Data #### | |
df.winners = read.csv( | |
"winnersWithMean.csv", | |
header = TRUE, | |
stringsAsFactors = FALSE, | |
na.strings = c("", "NA") | |
) | |
# dput for df.winners | |
# at the end of the code |
NewerOlder