Agr1 as character data2 Agriculture Agr2 lapply Agr1 as integer Agr3 a

 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
Agr1 = as.character(data2$Agriculture)
Agr2 = lapply(Agr1, as.integer)
Agr3 = as.numeric(unlist(Agr2))
data2["Agr"] = (Agr3 - mean(Agr3)) / sqrt(var(Agr3))
educ1 = as.character(data2$Education)
educ2 = lapply(educ1, as.integer)
educ3 = as.numeric(unlist(educ2))
data2["educ"] = (educ3 - mean(educ3)) / sqrt(var(educ3))
Cat1 = as.character(data2$Catholic)
Cat2 = lapply(Cat1, as.integer)
Cat3 = as.numeric(unlist(Cat2))
data2["Cat"] = (Cat3 - mean(Cat3)) / sqrt(var(Cat3))
data2["Agriculture_log"] = log(data2$Agriculture)
data2["Education_log"] = log(data2$Education)
data2["Catholic_log"] = log(data2$Catholic)
Agr1_log = as.character(data2$Agriculture_log)
Agr2_log = lapply(Agr1_log, as.integer)
Agr3_log = as.numeric(unlist(Agr2_log))
data2["Agr_log"] = (Agr3_log - mean(Agr3_log)) / sqrt(var(Agr3_log))
educ1_log = as.character(data2$Education_log)
educ2_log = lapply(educ1_log, as.integer)
educ3_log = as.numeric(unlist(educ2_log))
data2["educ_log"] = (educ3_log - mean(educ3_log)) / sqrt(var(educ3_log))
Cat1_log = as.character(data2$Catholic_log)
Cat2_log = lapply(Cat1_log, as.integer)
Cat3_log = as.numeric(unlist(Cat2_log))
data2["Cat_log"] = (Cat3 - mean(Cat3_log)) / sqrt(var(Cat3_log))