-
Notifications
You must be signed in to change notification settings - Fork 0
/
misc.jl
59 lines (45 loc) · 1.57 KB
/
misc.jl
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
## microbiome data join
# for mb join, we need to handle the waves in the more general case
# mdat = leftjoin(mb, dat, on = [:name, :village_code]);
# import JLD2; JLD2.save_object("userfiles/mb_processed.jld2", [mdat, nf, con]);
# core = ["personal_private", "closest_friend", "free_time"];
# health = ["health_advice_get", "health_advice_give"];
# nf = let
# # filter con to the mb village codes
# mbcodes = sort(unique(mb.village_code));
# rels = sort(unique(con.relationship));
# # union network
# nf = DataFrame();
# for w in 1:3
# # unionels = @subset(conns, :wave .== w); # all ties
# unionels = @subset(
# con, :wave .== w, :relationship .∈ Ref(core)
# ); # all ties
# # network calculations
# nfi = egoreductions(unionels, mbcodes, :village_code);
# nfi[!, :wave] .= w
# append!(nf, nfi)
# end
# nf
# end
# import JLD2; JLD2.save_object("userfiles/mb_processed.jld2", [mdat, nf, con]);
## USE FOR SOME PURPOSES
# nf = @chain nf begin
# select([:name, :village_code, :degree, :wave])
# DataFrames.unstack([:name, :village_code], :wave, :degree)
# rename(
# Symbol(1) => :degree_w1,
# Symbol(2) => :degree_w2,
# Symbol(3) => :degree_w3
# )
# # dropmissing([:degree_w1, :degree_w3])
# @transform(:Δdegree = :degree_w3 - :degree_w1)
# end
# mb_desc = describe(mb);
# dat = leftjoin(
# resp, hh,
# on = [
# :building_id, :village_code, :wave,
# :office, :municipality, :village_name
# ]
# );