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
# Copywrite Gabriel Bassett 2018 | |
# Not licensed for reuse | |
import copy | |
import operator | |
import uuid | |
import networkx as nx | |
import logging | |
import pprint | |
import simplejson as json |
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
#' A function to find github issues which may have been closed w/o being added | |
#' | |
#' NOTE: Many github issues have 'na' for their issue #, leading to false positives | |
#' NOTE: Requires ghql package, currently only at https://github.com/ropensci/ghql | |
#' `devtools::install_github("ropensci/ghql")` | |
#' | |
#' @param veris a verisr dataframe | |
#' @param gh_token a github user token for api access | |
#' @return a list of github issue numbers not in veris | |
#' @export |
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
{ | |
"$schema": "https://vega.github.io/schema/vega/v3.0.json", | |
"width": 500, | |
"height": 309, | |
"autosize": "pad", | |
"data": [ | |
{ | |
"name": ".", | |
"format": { | |
"type": "csv", |
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
#' Flip the x and y axis | |
#' | |
#' This is accomplished by updating the x & y marks, updating the flipping the | |
#' scales, and updating the axis labels. | |
#' | |
#' WARNING: This currently works for rectangular layer figures. It may not work with | |
#' multiple-layer figures, other marks, or signals. | |
#' | |
#' WARNING: No tests currently exist for this function | |
#' |
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
import networkx as nx # NOTE: written against dev networkx 2.0 | |
import logging | |
import inspect | |
import json | |
logger = logging.getLogger() | |
fileLogger = logging.FileHandler("~/Documents/Development/tmp/vega.log") | |
fileLogger.setLevel(logging.DEBUG) | |
logger.addHandler(fileLogger) |
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
{ | |
"$schema": "https://vega.github.io/schema/vega-lite/v2.json", | |
"vconcat": [ | |
{ | |
"data": { | |
"values": [ | |
{ | |
"enum": "victim.industry2.52", | |
"x": 471, | |
"n": 1935, |
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
# pick an enumeration | |
enum <- "action.*.variety" | |
# establish filter criteria (easier than a complex standard-eval filter_ line) | |
df <- vcdb %>% | |
dplyr::filter(plus.dbir_year == 2016, subset.2017dbir) %>% | |
dplyr::filter(attribute.confidentiality.data_disclosure.Yes) %>% | |
dplyr::filter(victim.industry2.92) | |
# establish priors from previous year | |
priors <- df %>% |
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
speedrun <- XML::xmlParse("/livesplit.lss") | |
speedrun <- XML::xmlToList(speedrun) | |
chunk <- do.call(rbind, lapply(speedrun[['Segments']], function(segments) { | |
segments.df <- do.call(rbind, lapply(segments[['SegmentHistory']], function(segment) { | |
if ('RealTime' %in% names(segment)) | |
data.frame(`attemptID` = segment$.attrs['id'], RealTime = segment$RealTime) | |
})) | |
segments.df$name <- rep(segments$Name, nrow(segments.df)) |
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
--- | |
title: "Test" | |
author: "Gabe" | |
date: "November 03, 2016" | |
output: html_document | |
params: | |
df: data.frame() | |
a: "" | |
b: "" | |
c: "FALSE" |
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
#' @param df Dataframe with x and y columns. (Hopefully in the future this can be x) | |
#' @param nlines The number of clusters. | |
#' @param ab a dataframe with a 'slopes' and 'intercepts' column and one row per initial line. Dimensions must match nlines. | |
#' @param maxiter The maximum number of iterations to do | |
#' @export | |
#' @examples | |
linearKMeans <- function(df, ab=NULL, nlines=0, maxiter=1000) { | |
# default number of lines | |
nlines_default <- 5 | |