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++.
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)