Politics

Here is the R script I am using for creating the maps and graphs of ADP for the State Senate and Congressional Districts

Here is the R script I am using for creating the maps and graphs of ADP for the State Senate and Congressional Districts. It should be interesting to see how it compares to the maps released by the special master. You can get the data here.

library(tidyverse)
library(tigris)
library(ggtext)
library(sf)

rm(list=ls())

# load latfor data, VTD level data is okay for larger districts
# although latfor also provides block level data which is better as
# those centroids should always be inside the district you are comparing
vt20 <- read_csv(‘2020vote_vtd.csv’)
vt20$GEOID <- as.character(vt20$GEOID)

# edADP – This code has to be as efficient as possible, as
# it can not be vectorized, due to the need to check to see
# if a race is competitive before including. We also don’t want
# to search for columns here, due to the CPU time cost over thousands
# of rows, each time searched.
edADP <- function(ed, demcols) {
 
  # making sure everything is numeric helps with speed
  ed <- ed %>% as.numeric
 
  # store a total of dems, rep, ballot votes
  dem <- 0; rep <- 0; ballot <- 0;
 
  # use democratic columns as an index for all other columns
  for (pos in demcols) {
    
    # if either Democratic or Republican line is 0, then that
    # multiplies out to zero as x * 0 = 0. Then negate and skip to next race
    if (!(ed[pos] *  ed[pos+1])) next;
    
    # to minimize costs, we just use row positions based on positition relative to
    # democratic rows
    dem <- dem + ed[pos]
    rep <- rep + ed[pos+1]   
    ballot <- ballot + ed[pos-1] – ed[pos+6]
  }
 
  # return the vote totals for all competitive races to bind to the main table
  return (c(‘dem’=dem, ‘rep’=rep, ‘ballot’=ballot))
}

dfADP <- function(df, yr=18) {
  # find position of dem cols before starting to minimize CPU costs when
  # doing the row-by-row math with apply
  demcols <- c()
 
  i <- 1
  for (dfcols in colnames(df)) {
    if (substr(dfcols, 1, 5) == str_c(‘DEM’,yr)) demcols <- append(demcols, i)
    i <- i+1
  }
 
  # Calculate ADP, row by row then bind to the dataframe
  return(cbind(df,df %>% apply(1, edADP, demcols) %>% t))
}

# calculate ADP from VT20 data
adp <- vt20 %>% dfADP(18)

# join the VTD data to voting districts
vtd <- voting_districts(‘ny’, cb=T) %>%
  inner_join(adp, by=c(‘GEOID20’=’GEOID’)) %>%
  st_transform(‘epsg:3857’)

# load the shapefile want to join the VTDs against
a22 <- read_sf(‘/home/andy/Documents/GIS.Data/2022-districts/Congress22.shp’) %>% st_transform(‘epsg:3857’)

name <- ‘Congress’

# for reasons of speed, convert VTDs to centroids, then join against
# the new districts
join <- vtd %>% st_centroid() %>%
  st_join(a22)

# calculate the ADP by dividing democratic votes in all competitive races against
# democrats and republican. Add column for coloring
join %>% st_drop_geometry() %>% group_by(DISTRICT) %>%
  summarise(ADP = (sum(dem)/sum(dem+rep))*100,
            color=ifelse(ADP > 60, ‘Democratic (>60%)’,
                         ifelse(ADP > 50, ‘Lean Democratic (>50%)’,
                                ifelse(ADP > 40, ‘Lean Republican (>40%)’, ‘Republican (<40%)’)))
            ) %>% drop_na() %>%
  ggplot(aes(DISTRICT, ADP, fill=color)) + geom_col(alpha=0.8) +
  geom_hline(yintercept = 50) +
  scale_fill_manual(values=c(‘blue’,’LightSkyBlue’,’Pink’,’Red’)) +
  scale_x_continuous(breaks=seq(1,64,1)) +
  scale_y_continuous(limits = c(0,100), breaks=seq(0,100,10)) +
  theme_minimal() +
  coord_cartesian(expand=F) +
  labs(
    title = str_c(‘<span style=”color: red;”>2018 Average</span> <span style=”color: blue;”>Democratic Performance</span> – ‘,name,’ \’22’),
    y = “2018 ADP (All races with Dem. and Rep. candidates)”,
    x = “”,
    caption=’Data Source: LATFOR VTDs’,
    tag=paste(‘Andy Arthur,’, format(Sys.Date(), format=”%-m/%-d/%y”)),
    fill = “”) +
  theme(
    text=element_text(family=’Open Sans’,size=14),
    plot.title=element_textbox( hjust=0.5, face=’bold’,size=34),
    axis.text = element_text(size=12),
    plot.background = element_rect(fill = “white”, color=”white”),
    plot.tag=element_text(size=10,hjust=0, color=’#555555′),
    plot.caption=element_text(size=10, color=’#555555′),
    plot.margin = unit(c(1,1,1,1), ‘lines’),
    plot.tag.position = c(0.0,0.01),
    legend.key.width = unit(4,’cm’),
    legend.key.height = unit(0.2,’cm’),
    legend.position = ‘top’
  )

fn <- str_c(’22-‘,name,’-graph’)
ggsave(paste(‘/tmp/’,fn,’.jpg’,sep=”), width=1920, height=1200, units=’px’, dpi=120)
ggsave(paste(‘/tmp/’,fn,’.svg’,sep=”), width=1920, height=1200, units=’px’, dpi=130, device = grDevices::svg)

# calculate the ADP by dividing democratic votes in all competitive races against
# democrats and republican. Add column for coloring
join %>% st_drop_geometry() %>% group_by(DISTRICT) %>%
  summarise(ADP = (sum(dem)/sum(dem+rep))*100,
            color=ifelse(ADP > 60, ‘Democratic (>60%)’,
            ifelse(ADP > 50, ‘Lean Democratic (>50%)’,
            ifelse(ADP > 40, ‘Lean Republican (>40%)’, ‘Republican (<40%)’))))  %>%
  drop_na() %>%
  inner_join(a22, by=(‘DISTRICT’)) %>%
  ggplot(aes(geometry=geometry, fill=color)) + geom_sf(size=0.5) +
  scale_fill_manual(values=c(‘blue’,’LightSkyBlue’,’Pink’,’Red’)) +
  theme_void() +
  coord_sf(expand=F) +
  labs(
    title = str_c(‘<span style=”color: red;”>2018 Average</span> <span style=”color: blue;”>Democratic Performance</span> – ‘,name,’ \’22’),
    caption=’Data Source: LATFOR VTDs’,
    tag=paste(‘Andy Arthur,’, format(Sys.Date(), format=”%-m/%-d/%y”)),
    fill = “”) +
  theme(
    text=element_text(family=’Open Sans’,size=14),
    plot.title=element_textbox( hjust=0.5, face=’bold’,size=34, margin=unit(c(0,0,1,0),’pt’)),
    plot.background = element_rect(fill = “white”, color=”white”),
    plot.tag=element_text(size=10,hjust=0, color=’#555555′),
    plot.caption=element_text(size=10, color=’#555555′),
    plot.margin = unit(c(1,1,1,1), ‘lines’),
    plot.tag.position = c(0.0,0.01),
    legend.key.width = unit(4,’cm’),
    legend.key.height = unit(.6,’cm’),
    legend.position = ‘top’
  )

fn <- str_c(’22-‘,name,’-map’)
ggsave(paste(‘/tmp/’,fn,’.jpg’,sep=”), width=1920, height=1200, units=’px’, dpi=120)
ggsave(paste(‘/tmp/’,fn,’.svg’,sep=”), width=1920, height=1200, units=’px’, dpi=130, device = grDevices::svg)

While I probably should follow politics closer then I do, I find J

While I probably should follow politics closer then I do, I find J.D. Vance’s run for US Senate to be fascinating. I really liked his book, Hillbilly Elegy. He’s somebody who knows the mud and muck of life, not some privileged suburbanite brat who has had everything handed to them on a silver plater.

We might be of opposite political parties and largely differentiating ideology, I totally get where he is coming from and I think he would be good representative for his community.

Banning Russia Today sets a dangerous precedent – The Post

Banning Russia Today sets a dangerous precedent – The Post

We need to know what is going on in Russia. Having access to the unfiltered Moscow line is vital when trying to understand Putin’s next steps. A prematurely published article celebrating Russia’s ‘victory’ over Ukraine was available on state-owned RIA-Novosti news agency and Sputnik’s site before being removed — a piece of journalism that revealed the extent of the Russian state’s disregard for Ukrainian sovereignty. By labelling this as dangerous ‘misinformation’, Dorries, von der Leyen and Clegg are preventing European citizens from getting the full picture on the political machinations coming out of the Kremlin.

Perhaps more importantly, the precedent set by such bold action as banning foreign news sites should make us worried. Press freedom has taken a bashing recently; during the pandemic, YouTube and other sites censored TalkRadio?for alleged Covid ‘misinformation’, while a recent BBC Stephen Nolan podcast revealed the extent to which Ofcom was willing to silence gender-critical views labelled ‘hate speech’. When it comes to interpreting foreign conflicts, the British government has proved itself to be similarly light?on principle. While British citizens who left to fight against ISIS with the Kurds were labelled terrorists and prosecuted on return, the foreign secretary Liz Truss announced her support for British citizens to fight with the Ukrainians against Russia during a broadcast round this weekend.???

Why I check Russia Today πŸ‡·πŸ‡Ί for the news πŸ“°

Why I check Russia Today πŸ‡·πŸ‡Ί for the news πŸ“°

For a long time I’ve been very interested in alternative perspectives not available on the mainstream media. I often think that sources like NPR are very one sided, too quick to dismiss other perspectives by calling them fake news and propaganda. But often alternative sources have good facts about what is happening on the ground, even if they have a different take on events based on alternative values.

People are quick to dismiss things that they disagree with as fake news. But when people and organizations are trying to censor things like Russia Today, then it’s all the more important to read up about them and learn their perspective and what parts of the conflict their highlighting. Russia Today is particularly good at highlighting the hypocrisy of the United States and the west when it comes to ideals of justice and fairness, even if they rarely look inwards to the problems of Russia. Just because they turn a blind eye to their country’s own problems or evils doesn’t mean they are fake.

By the same token, I also read the NY Post and Fox News not because I embrace all their pro police propaganda or sensationalist crime stories but because I like to be informed of the issues that concern conservative minded politicians. Not because I’m a right winger but because I like to hear the full spectrum of news and pick out stories and perspectives that make sense based on the evidence. Previously, I would read Inspire, the English translation of the recruiting magazine of Al Queda to be informed on how the Taliban saw the world.

My advice – visit RT.com regularly.

Reading the perspectives of the Russian government won’t brain wash you but will make you an informed citizen who is more understanding of the Russian society and culture. Understanding other cultures can help make you a voice for peace and an more informed person.