R, Julia, SQL, Octave and others: Personal notes on data analysis, computation, data access most especially for querying voter history, Census, PDC, and other election data. Reader is advised to just paste the code text into Notepad++.
Thursday, August 15, 2019
Code for age tables from post at http://www.bellinghampoliticsandeconomics.com/2019/08/election-summary-mostly-for-whatcom.html
Thursday, August 8, 2019
Ballot Returns by Status Date for 2018 Primary for BE,KP,TH,WM,YA
Election date for the charts below is 08/07/2018. In the "stampless ballot" era, the largest returns are often the day after the election. Drop boxes are probably fully collected but certainly locked by 8PM on election day. Mail in ballots sent Monday and Tuesday flow to postal collection centers (e.g. Seattle), receive a postmark in the evening and return the next day or the day after as mail is not necessarily delivered to County Elections offices on Tuesday. County election departments can 'process and then tabulate' a fixed amount each day at given labor/machine capacities. Thus, two days after the election is over, some counties are still processing ballots that are part of classical election returns and not part of certification period "curing" of previously rejected (e.g. challenged) ballots. Click to enlarge charts.
![]() |
| 2018 Primary Ballot Returns by StatusDate for BE, KP, TH, WM, YA. Election Date was 08/07/2018. |
| 2018 Primary Return Data came from multiple voting systems. Click to Enlarge. |
Saturday, July 27, 2019
Some PDC Contribution queries: Lovelett vs Blackwood 40th LD as of July 27 2019
Sunday, July 14, 2019
Divining come and gone voters from two different data slices four months apart
# Set proper paths for your data and data sets
# fread chokes on too many columns thus a workaround with rbind
# RMF 07/14/2019
# This is designed to be memory efficient non SQL
library(data.table)
library(lubridate)
library(lattice)
Saturday, March 2, 2019
FRBs: DM and width Density Plots
Chart 2 :Density plots for all DM and DM <= 1300
Chart 3: Density by group for DM
Chart 4: Density by group for width < 25
Chart 5: Density by group for width > 25
Source Paper: http://adsabs.harvard.edu/abs/2016PASA...33...45P
(For further citation information see below.)
data source : http://www.frbcat.org/ using 08.20.2019 data
Click to enlarge charts.
Wednesday, September 19, 2018
non-API tweet processing
tw201804.csv
tw201805.csv
tw201806.csv
tw201807.csv
tw201808.csv
tw201809.csv
The code far below row binds those six months together, removes the spaces between the column names, then chooses select columns with some configuration. The lattice library gives me the charts below. Binding together the metrics with time as a factor (~ likes + urlclicks + engagements | as.factor(time)) consolidates tweet metrics by day. Click to enlarge charts:
# you will need install.packages() for these libraries
library(bit64)
library(data.table)
library(lubridate)
library(lattice)
tw <- {}; for(i in 4:9) {tw <- rbind(tw,fread(paste0("C:\\Users\\rferrisx\\Downloads\\tw20180",i,".csv")))}
names(tw) <- tw[,gsub(" ","",names(tw))]
tw20180409 <- tw[,.(tweet=substr(Tweettext,1,40),
time=ymd(substr(time,0,10)),
impressions,
likes,
engagements,
engagePCT=round(engagementrate,3) * 100,
retweets,
replies,
urlclicks,
detailexpands)]
tw20180409[,Index:=.I]
tw20180409[,barchart(~ likes + urlclicks + engagements | as.factor(Index),allow.multiple=TRUE,origin=0,data=tw20180409,auto.key=list(rev=TRUE,reverse.rows=TRUE))]
tw20180409[,barchart(~ likes + urlclicks + engagements | as.factor(time),allow.multiple=TRUE,origin=0,data=tw20180409,auto.key=list(rev=TRUE,reverse.rows=TRUE))]
tw20180409[,barchart(~ likes + urlclicks + engagements | as.factor(tweet),allow.multiple=TRUE,origin=0,data=tw20180409,auto.key=list(rev=TRUE,reverse.rows=TRUE))]
tw20180409[,barchart(~ impressions | as.factor(time),allow.multiple=TRUE,origin=0,data=tw20180409,auto.key=list(rev=TRUE,reverse.rows=TRUE))]
tw20180409[,barchart(~ impressions | as.factor(Index),allow.multiple=TRUE,origin=0,data=tw20180409,auto.key=list(rev=TRUE,reverse.rows=TRUE))]
Tuesday, July 10, 2018
11.71875
## Ryan Matthew Ferris 10:26 PM Thursday, November 19, 2015, 2015 Bellingham, WA
## Updated 7/10/2018
## *Notes on 187.5/16 or 11.71875*
##
# In this code, I introduce 'xi' (11.71875) a constant with strong relationships to both pi and # exp(1).
# 'Xi' (11.71875 or (187.5/16)) is a 'translator constant' between powers of 2 and 16.
# Search google for "11.71875mhz" and you can see this. 11.71875mhz is a widely used frequency in 'crystal resonators'.
# More than simply being an efficient means to compute pi or exp(1) (e.g. 'Eulers number'), 'xi' may
# 'interpolate' between pi and e, giving science the means to measure logarithmic growth patterns of
# increasing radii. This may make it useful for gravitational and rotational calculations. It is
# possible that the 187.5 cm-3 pc represents some fixed attenuation limit (see
# http://arxiv.org/abs/1503.05245) for radio waves signal that require either boosting or
# chirping. The relationships between pi, e, and xi(187.5./16 = 11.71875) may represent fixed
# constants descriptive of all EM signaling. In addition, the constants that describe the
# circumscription of an octahedron (sqrt(1/2) and sqrt(1/6) can also be used to derive xi with a
# factor close to 9/16.
## A number of constants and function names are used. Some are reused:
# [1] "almost2" "aR" "c2" "cR" "eR" "F_pe" "F_pi" "findpi" "i" "j" "k" "k1"
# [13] "k2" "l" "l1" "mm1" "p1" "p2" "piR" "pR" "pX" "s4" "seqe" "seqpi"
# [25] "seqpi_e" "t1" "t2" "t3" "Vx" "x" "xi" "xi_sqrt" "xif" "y"
## Set your graphics device to record history if desired. 86 graphs are produced.
## You may want par(mfrow=c(1,2))
## NB : In R 3.5 there is no bigint by default,however there are 22 digits of accuracy.
## See my usage of BIGINT in Powershell
## For this work I used Microsoft Open R 3.5 with Intel's MKL (Math Kernel Library)


