Saturday, February 4, 2017

Decimal, Binary, Octal, Hexadecimal table

library(data.table)
library(R.utils)
print(setnames(data.table(cbind(2^0:128,intToBin(2^0:128),intToOct(2^0:128),intToHex(2^0:128))),c("Decimal","Binary","Oct","Hex"))[1:100])
     Decimal   Binary Oct Hex
  1:       1 00000001 001  01
  2:       2 00000010 002  02
  3:       3 00000011 003  03
  4:       4 00000100 004  04
  5:       5 00000101 005  05
  6:       6 00000110 006  06
  7:       7 00000111 007  07
  8:       8 00001000 010  08
  9:       9 00001001 011  09
 10:      10 00001010 012  0a
....
 t1 <- setnames(data.table(cbind(2^0:128,intToBin(2^0:128),intToOct(2^0:128),intToHex(2^0:128))),c("Decimal","Binary","Oct","Hex")) t1
     Decimal   Binary Oct Hex
  1:       1 00000001 001  01
  2:       2 00000010 002  02
  3:       3 00000011 003  03
  4:       4 00000100 004  04
  5:       5 00000101 005  05
 ---                         
124:     124 01111100 174  7c
125:     125 01111101 175  7d
126:     126 01111110 176  7e
127:     127 01111111 177  7f
128:     128 10000000 200  80
sapply(t1,class)
    Decimal      Binary         Oct         Hex 
"character" "character" "character" "character" 

Monday, May 16, 2016

Tale of Threes...

Groups of Voter per 42nd LD Precinct sorted into groups of threes: 3 Votes for last GEs (2013,2014,2015), Active but no votes for the last 3 GEs, NA for the last three GEs. Click to enlarge. Based on 4/15/2016 WC voterdb.

This code experiments with using data.table to group and select data. Political piece is here.

Tuesday, March 22, 2016

Checking Caucuses

Some tricky, dense political code that reveals information about Precinct Sites based on Voting History.  Ask if you need the spreadsheet. Political post here. Click to enlarge.



Code after the break.