-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLSA 977-982.R
71 lines (55 loc) · 2.33 KB
/
LSA 977-982.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
67
68
69
#COHHIO_HMIS
#Copyright (C) 2019 Coalition on Homelessness and Housing in Ohio (COHHIO)
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU Affero General Public License as published
#by the Free Software Foundation, either version 3 of the License, or
#any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU Affero General Public License for more details at
#<https://www.gnu.org/licenses/>.
# Distribution of FAM to IND beds vs HH w/ multiple clients and Singles served
library(tidyverse)
library(lubridate)
library(HMIS)
ReportStart <- "10012018"
ReportEnd <- "09302020"
Inventory <- read_csv("data/Inventory.csv")
Enrollment <- read_csv("data/Enrollment.csv")
Exit <- read_csv("data/Exit.csv")
smallInventory <- Inventory %>%
filter(beds_available_between(., ReportStart, ReportEnd)) %>%
select(ProjectID, HouseholdType, BedInventory) %>%
mutate(HouseholdType = case_when(
HouseholdType == 1 ~ "Individual",
HouseholdType == 3 ~ "Households",
HouseholdType == 4 ~ "ChildrenOnly"
))
x <- rowid_to_column(smallInventory)
hhtypes <- spread(x, HouseholdType, BedInventory) %>%
group_by(ProjectID) %>%
summarise(ChildrenOnlyBeds = sum(ChildrenOnly, na.rm = TRUE),
HouseholdBeds = sum(Households, na.rm = TRUE),
IndividualBeds = sum(Individual, na.rm = TRUE)) %>%
mutate(percentHHBeds = HouseholdBeds/
(HouseholdBeds + IndividualBeds))
smallEnrollment <- Enrollment %>%
left_join(Exit[c("EnrollmentID", "ExitDate")], by = "EnrollmentID") %>%
filter(served_between(., ReportStart, ReportEnd)) %>%
select(ProjectID, HouseholdID) %>%
mutate(HouseholdType = case_when(
grepl("s_", HouseholdID) == TRUE ~ "IndividualsServed",
grepl("h_", HouseholdID) == TRUE ~ "HouseholdsServed"
)) %>% unique()
y <- smallEnrollment %>%
group_by(ProjectID, HouseholdType) %>%
summarise(Count = n())
hhserved <- spread(y, HouseholdType, Count, fill = 0) %>%
mutate(percentHouseholds = HouseholdsServed/
(HouseholdsServed + IndividualsServed))
z <- full_join(hhtypes, hhserved)
possibleissues <- z %>%
mutate(
Diff = abs(percentHHBeds - percentHouseholds)) %>%
filter(Diff > .75)