-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path6 Table5- PrEP-PrEP.R
66 lines (53 loc) · 4.72 KB
/
6 Table5- PrEP-PrEP.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
61
62
63
64
65
66
# Table 5: PrEP-PrEP Mixing
rm(list = ls())
source('3 Analysis.R')
t5.title <- vector("character", 9)
t5.title[1] <- "Table 5. HIV-PrEP Sorting"
t5.colname.a <- vector("character", 9)
t5.colname.a[4] <- "Partners"
t5.colname.b <- c("", "Total, dyad-level", "", "No PrEP", "", "PrEP", "", "PrEP unknown", "")
t5.colname.c <- c("Respondents", "N", "Column %", "N", "Row %", "N", "Row %", "N", "Row %")
# Whole sample - egos and partners are HIV -/?
a <- artnetSort %>% filter(!p_hiv == "Pos", hiv3 == "Neg") %>% count(prep.during.ego2) %>% mutate(perc = round(100*n/sum(n), 1))
b <- artnetSort %>% filter(!p_hiv == "Pos", hiv3 == "Neg", prep.during.ego2 == "No") %>% count(prep.during.part2) %>% mutate(perc = round(100*n/sum(n), 1))
c <- artnetSort %>% filter(!p_hiv == "Pos", hiv3 == "Neg", prep.during.ego2 == "Yes") %>% count(prep.during.part2) %>% mutate(perc = round(100*n/sum(n), 1))
d <- artnetSort %>% filter(!p_hiv == "Pos", hiv3 == "Neg") %>% count(prep.during.part2) %>% mutate(perc = round(100*n/sum(n), 1))
t5.w <- rbind(
cbind("Whole Sample", "", "", "", "", "", "", "", ""),
cbind("No PrEP", a$n[1], a$perc[1], b$n[1], b$perc[1], b$n[2], b$perc[2], b$n[3], b$perc[3]),
cbind("PrEP", a$n[2], a$perc[2], c$n[1], c$perc[1], c$n[2], c$perc[2], c$n[3], c$perc[3]),
cbind("Total", sum(a$n), sum(a$perc), d$n[1], d$perc[1], d$n[2], d$perc[2], d$n[3], d$perc[3])
)
# Complete Case - partners are HIV negative and known PrEP use
a <- artnetSort %>% filter(p_hiv == "Neg", !prep.during.part2 == "Unk", hiv3 == "Neg") %>% count(prep.during.ego2) %>% mutate(perc = round(100*n/sum(n), 1))
b <- artnetSort %>% filter(p_hiv == "Neg", !prep.during.part2 == "Unk", hiv3 == "Neg", prep.during.ego2 == "No") %>% count(prep.during.part2) %>% mutate(perc = round(100*n/sum(n), 1))
c <- artnetSort %>% filter(p_hiv == "Neg", !prep.during.part2 == "Unk", hiv3 == "Neg", prep.during.ego2 == "Yes") %>% count(prep.during.part2) %>% mutate(perc = round(100*n/sum(n), 1))
d <- artnetSort %>% filter(p_hiv == "Neg", !prep.during.part2 == "Unk", hiv3 == "Neg") %>% count(prep.during.part2) %>% mutate(perc = round(100*n/sum(n), 1))
t5.c <- rbind(
cbind("Complete-case", "", "", "", "", "", "", "", ""),
cbind("No PrEP", a$n[1], a$perc[1], b$n[1], b$perc[1], b$n[2], b$perc[2], "", ""),
cbind("PrEP", a$n[2], a$perc[2], c$n[1], c$perc[1], c$n[2], c$perc[2], "", ""),
cbind("Total", sum(a$n), sum(a$perc), d$n[1], d$perc[1], d$n[2], d$perc[2], "", "")
)
# Reclassification
a <- results(dat = reclass.results, x = "eprep.pneg.n")
b <- results(dat = reclass.results, x = "eprep.pneg.p")
c <- results(dat = reclass.results, x = "pp.sort.n")
d <- results(dat = reclass.results, x = "pp.sort.p")
e <- results(dat = reclass.results, x = "ehiv.pneg.n")
f <- results(dat = reclass.results, x = "hp.sort.n")
g <- results(dat = reclass.results, x = "hp.sort.p")
t5.r <- rbind(
cbind("Reclassification", "", "", "", "", "", "", "", ""),
cbind("No PrEP", "", "", "", "", "", "", "", ""),
cbind("Median", round(a[1,2]), round(100*b[1,2],1), round(c[1,2]), round(100*d[1,2],1), round(c[3,2]), round(100*d[3,2],1), "", ""),
cbind("95% interval", paste0("(",round(a[1,1]),", ", round(a[1,3]), ")"), paste0("(",round(100*b[1,1],1),", ",round(100*b[1,3],1), ")"), paste0("(",round(c[1,1]),", ", round(c[1,3]), ")"), paste0("(",round(100*d[1,1],1),", ",round(100*d[1,3],1), ")"), paste0("(",round(c[3,1]),", ", round(c[3,3]), ")"), paste0("(",round(100*d[3,1],1),", ",round(100*d[3,3],1), ")"), "", ""),
cbind("PrEP", "", "", "", "", "", "", "", ""),
cbind("Median", round(a[2,2]), round(100*b[2,2],1), round(c[2,2]), round(100*d[2,2],1), round(c[4,2]), round(100*d[4,2],1), "", ""),
cbind("95% interval", paste0("(",round(a[2,1]),", ", round(a[2,3]), ")"), paste0("(",round(100*b[2,1],1),", ",round(100*b[2,3],1), ")"), paste0("(",round(c[2,1]),", ", round(c[2,3]), ")"), paste0("(",round(100*d[2,1],1),", ",round(100*d[2,3],1), ")"), paste0("(",round(c[4,1]),", ", round(c[4,3]), ")"), paste0("(",round(100*d[4,1],1),", ",round(100*d[4,3],1), ")"), "", ""),
cbind("Total", "", "", "", "", "", "", "", ""),
cbind("Median", round(e[1,2]), 100, round(f[1,2]), round(100*g[1,2],1), round(f[3,2]), round(100*g[3,2],1), "", ""),
cbind("95% interval", paste0("(",round(e[1,1]),", ", round(e[1,3]), ")"), "(1, 1)", paste0("(",round(f[1,1]),", ", round(f[1,3]), ")"), paste0("(",round(100*g[1,1],1),", ",round(100*g[1,3],1), ")"), paste0("(",round(f[3,1]),", ", round(f[3,3]), ")"), paste0("(",round(100*g[3,1],1),", ",round(100*g[3,3],1), ")"), "", "")
)
table5 <- rbind(t5.title, t5.colname.a, t5.colname.b, t5.colname.c, t5.w, t5.c, t5.r)
write.csv(table5, file = "aim1_table5_PP.csv")