Created
February 16, 2017 13:56
-
-
Save semenoffalex/0e31bfa6676d651fb47f94e2c9992894 to your computer and use it in GitHub Desktop.
R script for an article on CIS Miders rankings for empire.gg
This file contains hidden or 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
library(jsonlite) | |
library(data.table) | |
opendota.query <- function(sqlQuery) { | |
requestUrl = paste("https://api.opendota.com/api/explorer?sql=", URLencode(sqlQuery), sep="") | |
result <- fromJSON(requestUrl) | |
return(result$rows) | |
} | |
cis_mid_agg <- ' | |
SELECT | |
pm2.leagueid, | |
np.name, | |
pm2.start_time, | |
pm2.match_id, | |
pm2.account_id, | |
pm2.is_radiant, | |
pm2.win, | |
pm2.player_slot, | |
pm2.hero_id, | |
pm2.kills, | |
pm2.deaths, | |
pm2.assists, | |
pm2.gold, | |
pm2.last_hits, | |
pm2.denies, | |
pm2.gold_per_min, | |
pm2.xp_per_min, | |
pm2.gold_spent | |
FROM ( | |
SELECT | |
pm.account_id, | |
m.match_id, | |
m.start_time, | |
pm.player_slot, | |
pm.kills, | |
pm.deaths, pm.assists, pm.gold, pm.last_hits, pm.denies, pm.gold_per_min, pm.xp_per_min, | |
pm.gold_spent, m.leagueid, pm.hero_id, | |
(pm.player_slot < 100) AS is_radiant, | |
(pm.player_slot < 100) = m.radiant_win AS win | |
FROM ( | |
SELECT * | |
FROM player_matches | |
WHERE account_id IN (81852496, 96196828, 70388657, 87586992, 250114507, 113995822, 106573901, 237238721, 86840554, 113372833) | |
) pm | |
JOIN matches m ON pm.match_id = m.match_id | |
WHERE (m.start_time > 1460581200) and (m.start_time < 1504299600) | |
) pm2 | |
JOIN notable_players AS np ON pm2.account_id = np.account_id | |
' | |
cis_miders_m <- opendota.query(cis_mid_agg) | |
fwrite(cis_miders_m,'cis_miders_m.csv') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment