#' str_number
#'
#' This function loads the census data around class, dices by ward
#'calculates based on information provided from lucid talk for unionists
#' @return strangford_predictor output for UUP
#' @export str_number
#' @library dplyr
str_number <- function(LTABC, LTCTWO, abcweight,ctwodeweight){
load("~/andymacmillan/data/Dataset_3004_2011_1_.rda")
str_ds <- Dataset_3004_2011_1_ %>%
filter(Dataset_3004_2011_1_$Ward %in% c('Loughries', "Bradshaw's Brae",'Glen', 'Whitespots', 'Movilla', 'Carrowdore', 'Ballyrainey', 'Central (Ards LGD)','Gregstown', 'Scrabo', 'Comber West', 'Comber North', 'Moneyreagh', 'Comber East','Lisbane','Killinchy','Ballygowan','Portavogie', 'Kircubbin', 'Saintfield', 'Derryboy','Kilmore','Ballymaglave', 'Portaferry','Ballynahinch East', 'Killyleagh'))
str_ds$abcone <- str_ds$`Approximated social grade of HRP aged 16-64 years: AB` + str_ds$`Approximated social grade of HRP aged 16-64 years: C1`
str_ds$ctwode <- str_ds$`Approximated social grade of HRP aged 16-64 years: C2` + str_ds$`Approximated social grade of HRP aged 16-64 years: DE`
#lucidtalk numbers
LTABC = LTABC
LTCTWO = LTCTWO
str_ds$adbc_unweighted <- str_ds$abcone * LTABC
str_ds$ctwode_unweighted <- str_ds$ctwode * LTCTWO
#adjusted census 2011 with no exponetial growth
Religion <- c("None", "Catholic", "Protestant", "Other")
Number <- c(0.22, 0.41, 0.37, 0.01)
demographic <- cbind(Religion, Number)
demographic <- as.data.frame(demographic)
#assembly info demogaphic str with no exponetial growth
str_religion <- c("None", "Catholic", "Protestant", "Other")
str_number <- c(0.113, 0.177, 0.70,0.01)
str_demographic <- cbind(demographic, str_number)
str_demographic$Number <- as.numeric(str_demographic$Number)
str_demographic$ratio <- str_demographic$str_number/str_demographic$Number
str_ds$weighted_abc <- ((str_ds$adbc_unweighted*0.113)*0.5136364) +
((str_ds$adbc_unweighted*0.177)*0.4317073) +
((str_ds$adbc_unweighted*0.70)*1.8918919) +
((str_ds$adbc_unweighted*0.01)*1)
str_ds$weighted_ctwode <- ((str_ds$ctwode_unweighted*0.113)*0.5136364) +
((str_ds$ctwode_unweighted*0.177)*0.4317073) +
((str_ds$ctwode_unweighted*0.70)*1.8918919) +
((str_ds$ctwode_unweighted*0.01)*1)
str_ds$support_by_ward_raw <- (str_ds$weighted_abc*abcweight) + (str_ds$weighted_ctwode*ctwodeweight)
str_ds$percentage_ward <- str_ds$support_by_ward_raw / (str_ds$abcone + str_ds$ctwode)
str_ds[3] <- NULL
return(str_ds)}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.