<commit_before>rm(list=ls())
library(stringr)
library(plyr)
library(xts) # also pulls in zoo
library(timeDate)
library(chron)
library(descr)
library(reshape2)
library(ggplot2)
library(xtable)
##Detect problems with ward lookup
######################################
#File to recontact those registered with no look up info
########################################
workd <- "/Volumes/Optibay-1TB/RSA_RCT/QA/LiveData/VIP-LivedData/"

setwd(workd)

exports <- list.files(path=workd, pattern ="contact_2014_[0-9].*")

currentFile <-  tail(exports,1)[1]
setwd(paste0(workd,currentFile))

cat("Now loading the exports file from most recent file", currentFile, "\n\n")

exportFile <- read.csv("contacts-export.csv", header=TRUE, stringsAsFactors=FALSE,  na.strings="")

recontact <- exportFile[exportFile$extras.is_registered %in% c("true")  & is.na(exportFile$extras.raw_user_address), ]

#check
recontact[sample(nrow(recontact), 30), c("extras.raw_user_address", "extras.is_registered")]

numberstoSample <- recontact$msisdn

groups <- 3
elements <- 5000

set.seed(20140413)
recontactSample <- as.data.frame(matrix(sample(numberstoSample,size=(groups*elements)),nrow=elements, ncol=groups))
names(recontactSample) <-  c("group1", "group2", "group3")
                                
#WriteOutput
<commit_msg>Bug fix to make sure was delivered through USSD and right csv was used<commit_after>rm(list=ls())
library(stringr)
library(plyr)
library(xts) # also pulls in zoo
library(timeDate)
library(chron)
library(descr)
library(reshape2)
library(ggplot2)
library(xtable)
##Detect problems with ward lookup
######################################
#File to recontact those registered with no look up info
########################################
workd <- "/Volumes/Optibay-1TB/RSA_RCT/QA/LiveData/VIP-LivedData/"

setwd(workd)

exports <- list.files(path=workd, pattern ="contact_2014_[0-9].*")

currentFile <-  tail(exports,1)[1]
setwd(paste0(workd,currentFile))

cat("Now loading the exports file from most recent file", currentFile, "\n\n")

exportFile <- read.csv("contacts-export.csv", header=TRUE, stringsAsFactors=FALSE,  na.strings="")

recontact <- exportFile[exportFile$extras.is_registered %in% c("true") & exportFile$extras.delivery_class %in% c("ussd")  & is.na(exportFile$extras.raw_user_address), ]

#check
recontact[sample(nrow(recontact), 30), c("extras.raw_user_address", "extras.is_registered", "extras.delivery_class")]

numberstoSample <- recontact$msisdn

groups <- 3
elements <- ifelse( nrow(recontact) < 10000, floor(nrow(recontact)/3), 3333)


set.seed(20140413)
recontactSample <- as.data.frame(matrix(sample(numberstoSample,size=(groups*elements)),nrow=elements*groups, ncol=1))
names(recontactSample) <-  c("numbers")
recontactSample$group <- NA
recontactSample[1:elements, "group" ] <- "group1"
recontactSample[(elements+1):(elements+3334), "group"] <- "group2"
recontactSample[(elements*2+1):nrow(recontactSample),"group" ] <- "group3"

#> nrow(recontactSample[recontactSample$group%in% c("group1"),])


write.csv(recontactSample, file=paste0("recontactSample", Sys.Date(), ".csv"))

setwd("..")

{'fraction_non_alphanumeric': 0.19865211810012837, 'fraction_numerical': 0.02471116816431322, 'mean_word_length': 7.096103896103896, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5064354', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1033, 'n_words': 195}