Skip to content

Instantly share code, notes, and snippets.

@nateaff
nateaff / cran-view-last-month-downloads.r
Created October 10, 2022 00:12
Summarize total downloads in the last month of a Cran View
library(cranlogs)
library(ctv)
library(dplyr)
view <- "Optimization"
# Get Cran view packages
views <- ctv::available.views()
packages <- views[[view]]$packagelist
# See https://twitter.com/_fruchtose/status/1271280300228632576?s=20 for
# original twitter thread
comments <- read_csv("https://gist.githubusercontent.com/nateaff/5539054d77aab5d2e02f6254e3782143/raw/6531d52d3647c1636303824f7d11da0141136f09/matchanmore-dr.csv")
# Tokenize
comment_words <-
comments %>%
unnest_tokens(word, comment)
# Cretae custom stopwords for single word tokens
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 10.
position,comment
deny, First caller says that the Planning Commission shouldn't even be dealing with this kind of issue.
support," Second caller supports the DR applicant, who runs Garden Creamery."
deny, Third caller supports project sponsor Matcha n' More.
deny, Fourth caller is on board of Mission Merchants Association. This is a principally permitted use for the storefront. He supports the project sponsor.
support, Fifth caller is a customer of Garden Creamery and asks they deny the application of the other ice cream shop—because they have not consulted the community [the ice cream community?]
deny," Sixth caller supports Matcha n' More, saying we shouldn't deny their application for petty reasons."
support," Seventh caller is a small business owner, asks they support the DR. ""Community is more important than ever."" MnM ""has made that impossible"" by serving ice cream topped w/ 24K gold"
deny, Eighth caller supports MnM. They're serving an innovative style of ice cream.
deny," Ninth caller supports MnM
Line Mode Year daily_ridership
1 TC 2009 24300
2 MC 2009 7700
3 TC 2009 3500
4 TC 2009 1800
5/5R TC 2009 13000
5 MC 2009 0
6 TC 2009 8200
7 TC 2009 1800
7 MC 2009 10800
Line Mode FY09 FY10 FY11 FY12 FY13 FY14 FY15 FY16 FY17 FY18
1 TC 24300 24100 24800 25600 26000 25700 23800 23800 23500 23500
2 MC 7700 6700 5300 5900 5200 5400 4900 4800 5200 5200
3 TC 3500 3900 3200 3400 3400 4100 3700 3100 2500 2500
4 TC 1800 0 0 0 0 0 0 0 0 0
5/5R TC 13000 15900 18700 17200 17300 14900 11800 11800 11300 12900
5 MC 0 0 0 0 0 9600 9900 9700 8300 8400
6 TC 8200 8700 9100 10500 8500 7700 7400 7800 7800 7800
7 TC 1800 0 0 0 0 0 0 0 0 0
7 MC 10800 11800 10000 11400 10900 10100 10000 9800 9400 9400
mpg,cyl,rot,disp,hp,drat,wt,qsec,vs,am,gear,carb
21,0,2,160,110,3.9,2.62,16.46,0,1,4,4
21,0,2,160,110,3.9,2.875,17.02,0,1,4,4
22.8,4,0,108,93,3.85,2.32,18.61,1,1,4,1
21.4,6,0,258,110,3.08,3.215,19.44,1,0,3,1
18.7,8,0,360,175,3.15,3.44,17.02,0,0,3,2
18.1,6,0,225,105,2.76,3.46,20.22,1,0,3,1
14.3,8,0,360,245,3.21,3.57,15.84,0,0,3,4
24.4,4,0,146.7,62,3.69,3.19,20,1,0,4,2
22.8,4,0,140.8,95,3.92,3.15,22.9,1,0,4,2
@nateaff
nateaff / SPY_2015_11_03__2015_12_31.csv
Created April 10, 2018 02:27
SPY OHLC data for 2015-03-11 to 2015-12-31
Date Symbol Open High Low Close Volume
2015-11-03 SPY 209.970001220703 211.660003662109 209.699996948242 211 95246048
2015-11-04 SPY 211.350006103516 211.5 209.720092773438 210.360000610352 96224480
2015-11-05 SPY 210.429992675781 210.979995727539 209.089996337891 210.149993896484 78408744
2015-11-06 SPY 209.740005493164 210.320007324219 208.460006713867 210.039993286133 110471472
2015-11-09 SPY 209.309997558594 209.490005493164 206.949996948242 208.080001831055 131008656
2015-11-10 SPY 207.509994506836 208.600006103516 207.190002441406 208.559997558594 75874600
2015-11-11 SPY 208.880004882812 208.940002441406 207.660003662109 207.740005493164 67845968
2015-11-12 SPY 206.5 207.059997558594 204.820007324219 204.839996337891 121315200
2015-11-13 SPY 204.350006103516 204.669998168945 202.434997558594 202.539993286133 153577056
@nateaff
nateaff / US Zip Codes from 2013 Government Data
Created November 8, 2017 21:45 — forked from erichurst/US Zip Codes from 2013 Government Data
All US zip codes with their corresponding latitude and longitude coordinates. Comma delimited for your database goodness. Source: http://www.census.gov/geo/maps-data/data/gazetteer.html
This file has been truncated, but you can view the full file.
ZIP,LAT,LNG
00601,18.180555, -66.749961
00602,18.361945, -67.175597
00603,18.455183, -67.119887
00606,18.158345, -66.932911
00610,18.295366, -67.125135
00612,18.402253, -66.711397
00616,18.420412, -66.671979
00617,18.445147, -66.559696
@nateaff
nateaff / .block
Last active October 7, 2017 01:56 — forked from mbostock/.block
Bar Chart IIc
license: gpl-3.0
height: 300
width: 420
scrolling: no
@nateaff
nateaff / test-xgboost-explainer
Created October 7, 2017 00:07
Run the `xgboostExplainer::buildExplainer` function on all example models from `xgboost()`
library(xgboost)
library(xgboostExplainer)
xgboost_example_models <- function(){
# Return a list of all the examples from the xgboost() documentation
data(agaricus.train, package='xgboost')
data(agaricus.test, package='xgboost')
dtrain <- xgb.DMatrix(agaricus.train$data, label = agaricus.train$label)