-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract_outcomes.R
60 lines (48 loc) · 3.32 KB
/
extract_outcomes.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
library(RSQLite)
sqlitedb.filename <- file.path("db", "kdd_cup_data.sqlite3")
print("Extraction donnees outcomes...")
# Outcomes data
drv <- dbDriver("SQLite")
con <- dbConnect(drv, dbname=sqlitedb.filename)
outcomes.data <- dbGetQuery(
con,
"
select
*
from outcomes
"
)
dbDisconnect(con)
outcomes.data <- outcomes.data[, colnames(outcomes.data) != "row_names"]
# Normalizae
outcomes.data$is_exciting <- factor(ifelse(outcomes.data$is_exciting == "t", "Yes", "No"))
outcomes.data$at_least_1_teacher_referred_donor[outcomes.data$at_least_1_teacher_referred_donor == ""] <- NA
outcomes.data$at_least_1_teacher_referred_donor[outcomes.data$at_least_1_teacher_referred_donor == "t"] <- "Yes"
outcomes.data$at_least_1_teacher_referred_donor[outcomes.data$at_least_1_teacher_referred_donor == "f"] <- "No"
outcomes.data$at_least_1_teacher_referred_donor <- factor(outcomes.data$at_least_1_teacher_referred_donor)
outcomes.data$fully_funded[outcomes.data$fully_funded == ""] <- NA
outcomes.data$fully_funded[outcomes.data$fully_funded == "t"] <- "Yes"
outcomes.data$fully_funded[outcomes.data$fully_funded == "f"] <- "No"
outcomes.data$fully_funded <- factor(outcomes.data$fully_funded)
outcomes.data$at_least_1_green_donation[outcomes.data$at_least_1_green_donation == ""] <- NA
outcomes.data$at_least_1_green_donation[outcomes.data$at_least_1_green_donation == "t"] <- "Yes"
outcomes.data$at_least_1_green_donation[outcomes.data$at_least_1_green_donation == "f"] <- "No"
outcomes.data$at_least_1_green_donation <- factor(outcomes.data$at_least_1_green_donation)
outcomes.data$three_or_more_non_teacher_referred_donors[outcomes.data$three_or_more_non_teacher_referred_donors == ""] <- NA
outcomes.data$three_or_more_non_teacher_referred_donors[outcomes.data$three_or_more_non_teacher_referred_donors == "t"] <- "Yes"
outcomes.data$three_or_more_non_teacher_referred_donors[outcomes.data$three_or_more_non_teacher_referred_donors == "f"] <- "No"
outcomes.data$three_or_more_non_teacher_referred_donors <- factor(outcomes.data$three_or_more_non_teacher_referred_donors)
outcomes.data$one_non_teacher_referred_donor_giving_100_plus[outcomes.data$one_non_teacher_referred_donor_giving_100_plus == ""] <- NA
outcomes.data$one_non_teacher_referred_donor_giving_100_plus[outcomes.data$one_non_teacher_referred_donor_giving_100_plus == "t"] <- "Yes"
outcomes.data$one_non_teacher_referred_donor_giving_100_plus[outcomes.data$one_non_teacher_referred_donor_giving_100_plus == "f"] <- "No"
outcomes.data$one_non_teacher_referred_donor_giving_100_plus <- factor(outcomes.data$one_non_teacher_referred_donor_giving_100_plus)
outcomes.data$donation_from_thoughtful_donor[outcomes.data$donation_from_thoughtful_donor == ""] <- NA
outcomes.data$donation_from_thoughtful_donor[outcomes.data$donation_from_thoughtful_donor == "t"] <- "Yes"
outcomes.data$donation_from_thoughtful_donor[outcomes.data$donation_from_thoughtful_donor == "f"] <- "No"
outcomes.data$donation_from_thoughtful_donor <- factor(outcomes.data$donation_from_thoughtful_donor)
outcomes.data$great_chat[outcomes.data$great_chat == ""] <- NA
outcomes.data$great_chat[outcomes.data$great_chat == "t"] <- "Yes"
outcomes.data$great_chat[outcomes.data$great_chat == "f"] <- "No"
outcomes.data$great_chat <- factor(outcomes.data$great_chat)
# Nettoyage
rm(list=c("con", "drv", "sqlitedb.filename"))