Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .RData
Binary file not shown.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
data_vis.pbix
my_app_id.R
data_exploration.html
Process flow chart.jpg
experimental_dashboard.pbix
README.html
other documents & archive
3 changes: 1 addition & 2 deletions R/functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ get_charity_fundraising_pages <- function(charity_name, id){
reduce(bind_rows)%>%
mutate(charity = charity_name,
searched_charity_id = id)%>%
filter(searched_charity_id==CharityId)
filter(searched_charity_id==CharityId) #filter out where id's do not match ('justgiving_id')
return(fundraisers_data)
}
#DO: filter on id=CharityID (and use justgiving_id in calling this)

#This takes a fundraisers id and gets the data for it (a single row of info)
get_fundraising_data <- function(fundraiser_id){
Expand Down
17 changes: 7 additions & 10 deletions R/just_giving_data_pull.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
charity_data <- charities_csv %>%
read_csv %>%
#drop_na(charity_name, regno)
drop_na(charity_name, justgiving_id)
#drop if there IS no 'justgiving_id'
drop_na(charity_name, justgiving_id) #drop if there IS no 'justgiving_id'

#%>% filter(give_well_top_2017==1 | give_well_standout_2017==1)
#%>% filter(give_well_top_2017==1 | give_well_standout_2017==1)

#Get all fundraisers for target charities (just basic information)
fundraiser_search_data <-
Expand All @@ -19,20 +18,18 @@ fundraiser_search_data <-

fundraiser_search_data_2018 <- fundraiser_search_data %>%
mutate(date_created=date(CreatedDate)) %>%
filter(date_created>"2018-01-01")
filter(date_created>"2018-06-01")


#Sample of 50 for testing... fundraiser_search_data <- tail(fundraiser_search_data,n=50)
#sample wateraid: fundraiser_search_data_w<- filter(fundraiser_search_data,charity=="WaterAid")
#fundraiser_search_data_a<-filter(fundraiser_search_data,charity=="Animal Equality")
#Note -- I did a check on these smaller charities -- the filtering below seems to be correct
#Sample of 10 for testing... fundraiser_search_data_t <- tail(fundraiser_search_data,n=10)
#sample wateraid: fundraiser_search_data_w<- filter(fundraiser_search_data,charity=="WaterAid")
#fundraiser_search_data_a<-filter(fundraiser_search_data,charity=="Animal Equality")

#Get info about the fundraisers
fundraising_page_data <-
map(fundraiser_search_data$Id, get_fundraising_data) %>%
reduce(bind_rows) %>%
left_join(fundraiser_search_data, by = c('pageId' = 'Id')) %>%
dplyr::filter(unlist(Map(function(x, y) grepl(x, y), searched_charity_id, charity.registrationNumber))) %>% #match the 'regno' ... if it is *present* in the other variable (some give several regno's)
#dplyr::filter(unlist(Map(function(x, y) grepl(x, y), searched_charity_id, charity.registrationNumber))) %>% -- removed as already done above ... match the 'regno' ... if it is *present* in the other variable (some give several regno's)
select(-grep('image.', names(.))) %>%
select(-grep('videos.', names(.)))%>%
select(-grep('branding.', names(.))) %>%
Expand Down
Binary file added README.pdf
Binary file not shown.
5 changes: 3 additions & 2 deletions main.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ charities_csv <- file.path(data_folder, 'effective_charities.csv') #replace with
#A folder that contains all the fundraising and donation data, a new copy each time the code is run
snapshots_folder <- file.path(data_folder, 'just_giving_data_snapshots')

#In the get_current... file, We don't look at pages with first donation that comes before the
experiment_start_date <- as.Date('2018/04/13') #REMEMBER to reset this!!
#In the get_current... file, We don't look at pages with first donation that comes before the...
experiment_start_date <- as.Date('2019/07/13') #REMEMBER to reset this!!
date = Sys.Date()
time = Sys.time()

Expand All @@ -38,5 +38,6 @@ source("my_app_id.R")
source("R/functions.R")
#Downloads all current data for the target charities, also saves a snapshot
source("R/just_giving_data_pull.R")

#Performs the randomisation, outputs a file listing all new treatment groups, and saves the current state of experimental pages
source("R/get_current_state_and_randomise.R")