Skip to content

Instantly share code, notes, and snippets.

@semenoffalex
semenoffalex / readmarvelcharacternets.r
Created June 2, 2022 16:24
Ben Lind's script for backbone projection applied to Marvel Universe Social Network
# The following script was written by Benjamin Lind (@benjaminlind)
# It implements methods, described in the paper:
# Neal, Zachary. "The backbone of bipartite projections: Inferring relationships from co-authorship, co-sponsorship, co-attendance and other co-behaviors." Social Networks 39 (2014): 84-97.
# https://www.sciencedirect.com/science/article/abs/pii/S0378873314000343
#
# The Marvel Universe Social Network
# Dataset created by Cesc Rosselló, Ricardo Alberich, and Joe Miro
# The network data is bipartite. There are characters and the books they appear within.
# Information on the data: http://bioinfo.uib.es/~joemiro/marvel.html
# Primary source: http://www.chronologyproject.com/
@semenoffalex
semenoffalex / wiki_style_timeline.R
Last active June 8, 2019 10:50
Trying to make a Wikipedia-style timeline in R
library(rvest)
library(tidyverse)
library(lubridate)
library(scales)
library(Cairo)
library(lubridate)
url <- "https://liquipedia.net/dota2/Team_Secret"
page <- read_html(url)
@semenoffalex
semenoffalex / ti8_fantasy_dashboard.r
Created August 29, 2018 15:58
R script for getting and visualizing data about TI8 fantasy league
library(rvest)
library(tidyverse)
library(googlesheets)
# Getting results table from fantasy prizetrac
overview <- read_html("http://fantasy.prizetrac.kr/views/international2018/overview.php")
fpoints <- html_table(overview)[[1]]
# Team names for cleaning players' names
teams <- c("FnaticFnatic", "VGJ.StormVGJS", "OGOG", "Evil GeniusesEG",
@semenoffalex
semenoffalex / shiny_arules.R
Created December 31, 2017 18:56 — forked from brooksandrew/shiny_arules.R
Launches a Shiny App that provides an interactive interface to the arules and arulesViz package which train and visualize association rules
#' @title Assocation Rules Visualization Shiny App
#' @description Launches a Shiny App that provides an interactive interface to the visualizations of the \code{arulesViz} package.
#' The app allows users to mine rules based on all or just subsets of features, sort by criteria (lift, support, confidence) and visualize
#' using network graph, grouped bubble and scatter plots. \cr
#' Users filter rules to target only those with a certain variable on the RHS or LHS of the rule.
#' Rule mining is computed using the \link{apriori} algorithm from \code{arules}.
#'
#' @param dataset data.frame, this is the dataset that association rules will be mined from. Each row is treated as a transaction. Seems to work
#' OK when a the S4 transactions class from \code{arules} is used, however this is not thoroughly tested.
#' @param bin logical, \code{TRUE} will automatically discretize/bin numerical data into categorical features that can be used for association analysis.
@semenoffalex
semenoffalex / reddit_report.md
Created October 24, 2017 14:58
Reddit_report_markdown_template

Teams

Team Avarege Shortest Longest Total Radiant Dire
Immortals 35:37 27:20 50:46 6 / 11 (54.5%) 3 / 5 (60.0%) 3 / 6 (50.0%)
Mineski.YDB 38:42 25:15 74:16 8 / 10 (80.0%) 3 / 3 (100.0%) 5 / 7 (71.4%)
Evil Geniuses 42:51 21:58 82:16 4 / 9 (44.4%) 3 / 5 (60.0%) 1 / 4 (25.0%)
LGD-GAMING 33:54 28:55 38:15 6 / 9 (66.7%) 3 / 5 (60.0%) 3 / 4 (75.0%)
VGJ Thunder 43:06 21:58 82:16 3 / 8 (37.5%) 1 / 3 (33.3%) 2 / 5 (40.0%)
Team Secret 41:45 29:58 54:39 3 / 7 (42.9%) 3 / 5 (60.0%) 0 / 2 (0.0%)
@semenoffalex
semenoffalex / dota2_unknown_pleasures.R
Last active October 14, 2017 14:00
Code to create a Joy Division 'Unknown Pleasures' album cover with data from Dota 2 match duration by month
library(tidyverse)
library(jsonlite)
library(lubridate)
library(ggridges)
opendota_query <- function(sqlQuery) {
requestUrl = paste("https://api.opendota.com/api/explorer?sql=",
URLencode(sqlQuery), sep="")
result <- fromJSON(requestUrl)
return(result$rows)
}
@semenoffalex
semenoffalex / cis_miders_performance.r
Created February 16, 2017 13:56
R script for an article on CIS Miders rankings for empire.gg
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 <- '
q_miders <- "
SELECT
pm2.leagueid,
pm2.start_time,
pm2.match_id,
pm2.account_id,
pm2.is_radiant,
pm2.win,
pm2.player_slot,
pm2.hero_id,