Import data

load("~/Madness/nmhss_2019_puf_R.RData")


load("~//Madness/N-MHSS-2010-DS0001-data/N-MHSS-2010-DS0001-data-r.rda")

rename data sets

treatments_2019 <-PUF
treatments_2010 <- da34945.0001

#3 Clean 2019

library(dplyr)
## Warning: package 'dplyr' was built under R version 4.0.4
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyr)
## Warning: package 'tidyr' was built under R version 4.0.4
treat_cleaned_2019 <- treatments_2019 %>%
  #select treatment variables 
  select(starts_with("TREAT")) %>%
  pivot_longer(cols = everything(), names_to = "treatment", values_to = "count") %>%
  #compute percentages of facilities that offer the treatment
  group_by(treatment) %>%
  summarise(percent = mean(count)) %>%
  mutate(treatment = case_when(
    treatment == "TREATPSYCHOTHRPY" ~ "psychotherapy",
    treatment == "TREATFAMTHRPY" ~ "family therapy",
    treatment == "TREATGRPTHRPY" ~ "group therapy",
    treatment == "TREATCOGTHRPY" ~ "cognitive behavioral therapy",
    treatment == "TREATDIALTHRPY" ~ "dialectical behavior therapy",
    treatment == "TREATBEHAVMOD" ~ "behavior modification",
    treatment == "TREATDUALMHSA" ~ "integrated dual disorders treatment",
    treatment == "TREATTRAUMATHRPY" ~ "trauma therapy",
    treatment == "TREATACTVTYTHRPY" ~ "activity therapy",
    treatment == "TREATELECTRO" ~ "electroconvulsive therapy",
    treatment == "TREATTELEMEDINCE" ~ "telemedicine therapy",
    treatment == "TREATPSYCHOMED" ~ "psychotropic medication",
    treatment == "TREATOTH" ~ "mentalhealth treatment approach",
    treatment == "TREATMT" ~ "substanceuse treatment",
    TRUE ~ as.character(treatment)))

treat_cleaned_2019 
## # A tibble: 14 x 2
##    treatment                           percent
##    <chr>                                 <dbl>
##  1 activity therapy                     0.446 
##  2 behavior modification                0.660 
##  3 cognitive behavioral therapy         0.902 
##  4 dialectical behavior therapy         0.563 
##  5 integrated dual disorders treatment  0.566 
##  6 electroconvulsive therapy            0.0410
##  7 family therapy                       0.725 
##  8 group therapy                        0.856 
##  9 substanceuse treatment               0.563 
## 10 mentalhealth treatment approach      0.0585
## 11 psychotropic medication              0.818 
## 12 psychotherapy                        0.916 
## 13 telemedicine therapy                 0.380 
## 14 trauma therapy                       0.773
library(skimr)
## Warning: package 'skimr' was built under R version 4.0.3
skim(da34945.0001)
Data summary
Name da34945.0001
Number of rows 10374
Number of columns 237
_______________________
Column type frequency:
factor 119
numeric 118
________________________
Group variables None

Variable type: factor

skim_variable n_missing complete_rate ordered n_unique top_counts
STFIPS 0 1.00 FALSE 52 (06: 927, (36: 685, (42: 541, (17: 512
MODE 0 1.00 FALSE 4 (4): 5538, (3): 2535, (1): 1726, (2): 575
MHINTAKE 623 0.94 FALSE 2 (1): 8208, (0): 1543
MHDIAGEVAL 622 0.94 FALSE 2 (1): 8253, (0): 1499
MHREFERRAL 626 0.94 FALSE 2 (1): 6630, (0): 3118
SASERV 625 0.94 FALSE 2 (1): 4897, (0): 4852
MENTALHTHSERV 0 1.00 FALSE 1 (1): 10374
ADMINSERV 653 0.94 FALSE 2 (1): 5802, (0): 3919
SETTINGIP 0 1.00 FALSE 2 (0): 8399, (1): 1975
SETTINGRC 0 1.00 FALSE 2 (0): 8100, (1): 2274
SETTINGOP 0 1.00 FALSE 2 (1): 7931, (0): 2443
FACILITYTYPE 0 1.00 FALSE 6 (5): 6468, (2): 1238, (4): 878, (3): 781
FOCUS 630 0.94 FALSE 2 (1): 7287, (3): 2457
OWNERSHIP 0 1.00 FALSE 8 (2): 6968, (1): 996, (7): 953, (3): 727
RELIGIOUS 682 0.93 FALSE 2 (0): 8876, (1): 816
TREATACTVTYTHRPY 1297 0.87 FALSE 2 (1): 4676, (0): 4401
TREATBEHAVMOD 1294 0.88 FALSE 2 (1): 5950, (0): 3130
TREATCOGTHRPY 1291 0.88 FALSE 2 (1): 8061, (0): 1022
TREATFAMTHRPY 1293 0.88 FALSE 2 (1): 6129, (0): 2952
TREATELECTRO 1342 0.87 FALSE 2 (0): 8459, (1): 573
TREATGRPTHRPY 1292 0.88 FALSE 2 (1): 7742, (0): 1340
TREATPSYCHOTHRPY 1286 0.88 FALSE 2 (1): 7844, (0): 1244
TREATDUALMHSA 1331 0.87 FALSE 2 (1): 4967, (0): 4076
TREATPSYCHOMED 1289 0.88 FALSE 2 (1): 7601, (0): 1484
TREATTELEMEDINCE 1372 0.87 FALSE 2 (0): 7593, (1): 1409
TREATOTH 1240 0.88 FALSE 2 (0): 8371, (1): 763
ASSERTCOMM 1333 0.87 FALSE 2 (0): 7420, (1): 1621
MHCASEMGMT 1298 0.87 FALSE 2 (1): 6741, (0): 2335
MHCHRONIC 1351 0.87 FALSE 2 (0): 7174, (1): 1849
MHCONSUMER 1327 0.87 FALSE 2 (0): 7352, (1): 1695
MHEDUCATION 1317 0.87 FALSE 2 (0): 4991, (1): 4066
FAMPSYCHED 1316 0.87 FALSE 2 (1): 5490, (0): 3568
MHHOUSING 1333 0.87 FALSE 2 (0): 6870, (1): 2171
ILLNESSMGMT 1341 0.87 FALSE 2 (0): 6006, (1): 3027
MHLEGAL 1358 0.87 FALSE 2 (0): 8250, (1): 766
MHEMGCY 1328 0.87 FALSE 2 (0): 5654, (1): 3392
MHPSYCHREHAB 1334 0.87 FALSE 2 (0): 4693, (1): 4347
SMOKINGCESSATION 1326 0.87 FALSE 2 (0): 6858, (1): 2190
MHSUICIDE 1325 0.87 FALSE 2 (1): 5230, (0): 3819
SUPPEMPLOY 1333 0.87 FALSE 2 (0): 7157, (1): 1884
SUPPHOUSING 1339 0.87 FALSE 2 (0): 7336, (1): 1699
FOSTERCARE 1354 0.87 FALSE 2 (0): 8370, (1): 650
MHVOCREHAB 1351 0.87 FALSE 2 (0): 7564, (1): 1459
MHOTH 1241 0.88 FALSE 2 (0): 8605, (1): 528
CHILDADOL 1242 0.88 FALSE 2 (1): 5781, (0): 3351
ADULTS 1250 0.88 FALSE 2 (1): 7810, (0): 1314
SENIORS 1247 0.88 FALSE 2 (1): 6870, (0): 2257
SED 1266 0.88 FALSE 2 (0): 5164, (1): 3944
TRANSITIONAGE 1280 0.88 FALSE 2 (0): 6347, (1): 2747
SPMI 1277 0.88 FALSE 2 (1): 5738, (0): 3359
ALZHDEMENTIA 1298 0.87 FALSE 2 (0): 7911, (1): 1165
MHANDSA 1276 0.88 FALSE 2 (1): 5333, (0): 3765
MHANDOTHER 1288 0.88 FALSE 2 (0): 4787, (1): 4299
POSTTRAUM 1275 0.88 FALSE 2 (1): 4569, (0): 4530
VETERNS 1317 0.87 FALSE 2 (0): 6971, (1): 2086
TRAUMATICBRAIN 1322 0.87 FALSE 2 (0): 7995, (1): 1057
GLBT 1304 0.87 FALSE 2 (0): 6665, (1): 2405
FORENSIC 1288 0.88 FALSE 2 (0): 6100, (1): 2986
PROGOTH 1237 0.88 FALSE 2 (0): 8569, (1): 568
HEARIMPAIR 1322 0.87 FALSE 2 (1): 5510, (0): 3542
LANGENGLISH 1247 0.88 FALSE 2 (1): 9084, (0): 43
LANGSPANISH 1250 0.88 FALSE 2 (0): 5705, (1): 3419
LANGOTH 1249 0.88 FALSE 2 (0): 8367, (1): 758
CRISISTEAM 1278 0.88 FALSE 4 (4): 3803, (3): 2185, (1): 2157, (2): 951
COMPRESULTRPTG 1277 0.88 FALSE 2 (0): 5331, (1): 3766
COMPCPOE 1301 0.87 FALSE 2 (0): 6407, (1): 2666
COMPCLINDATA 1298 0.87 FALSE 2 (0): 6283, (1): 2793
COMPREFERRALS 1284 0.88 FALSE 2 (0): 7059, (1): 2031
COMPTREATPLAN 1267 0.88 FALSE 2 (1): 6166, (0): 2941
COMPSATISFYSURVEY 1292 0.88 FALSE 2 (0): 6462, (1): 2620
COMPMEDCHECK 1332 0.87 FALSE 2 (0): 5358, (1): 3684
COMPBILLING 1304 0.87 FALSE 2 (1): 7478, (0): 1592
COMPPATIENTSCHED 1286 0.88 FALSE 2 (1): 5767, (0): 3321
COMPPROCESSNOTE 1286 0.88 FALSE 2 (1): 5852, (0): 3236
COMPOTH 1241 0.88 FALSE 2 (0): 8745, (1): 388
EDUCREQUIRE 1257 0.88 FALSE 2 (1): 8147, (0): 970
CASEREVIEW 1258 0.88 FALSE 2 (1): 8342, (0): 774
COMMITTEE 1273 0.88 FALSE 2 (1): 6399, (0): 2702
OUTCOME 1279 0.88 FALSE 2 (1): 4882, (0): 4213
UTILIZATION 1275 0.88 FALSE 2 (1): 8298, (0): 801
SATISFYSURVEY 1266 0.88 FALSE 2 (1): 8583, (0): 525
NOCHARGE 1298 0.87 FALSE 2 (1): 5537, (0): 3539
FEESCALE 1361 0.87 FALSE 2 (1): 5527, (0): 3486
FUNDMEDICAID 1263 0.88 FALSE 2 (1): 8062, (0): 1049
FUNDMEDICARE 1279 0.88 FALSE 2 (1): 6324, (0): 2771
FUNDSMHA 1354 0.87 FALSE 2 (1): 6466, (0): 2554
FUNDSTATEWELFARE 1341 0.87 FALSE 2 (0): 4941, (1): 4092
FUNDSTATEJUV 1319 0.87 FALSE 2 (0): 6123, (1): 2932
FUNDSTATEEDUC 1345 0.87 FALSE 2 (0): 7107, (1): 1922
FUNDLOCALGOV 1341 0.87 FALSE 2 (0): 4540, (1): 4493
FUNDVA 1335 0.87 FALSE 2 (0): 6862, (1): 2177
FUNDCSBG 1403 0.86 FALSE 2 (0): 6757, (1): 2214
FUNDCMHG 1392 0.87 FALSE 2 (0): 5607, (1): 3375
FUNDCLIENTFEES 1282 0.88 FALSE 2 (1): 7689, (0): 1403
FUNDPRVTINS 1291 0.88 FALSE 2 (1): 7166, (0): 1917
FUNDOTHPUB 1261 0.88 FALSE 2 (0): 8586, (1): 527
FUNDOTHPRVT 1268 0.88 FALSE 2 (0): 8419, (1): 687
MAJORSINGLEFUND 1445 0.86 FALSE 2 (1): 5913, (0): 3016
MAJORFUNDTYPE 4522 0.56 FALSE 14 (01: 3320, (03: 958, (02: 402, (12: 269
SMOKINGPOLICY 1256 0.88 FALSE 5 (2): 4537, (1): 3806, (3): 714, (5): 55
USEDSECLUSION 1289 0.88 FALSE 2 (0): 6476, (1): 2609
ADOPTSECLUSION 1643 0.84 FALSE 2 (0): 4796, (1): 3935
LICENSESMHA 1341 0.87 FALSE 2 (1): 6727, (0): 2306
LICENSESA 1362 0.87 FALSE 2 (0): 6241, (1): 2771
LICENSEDPH 1399 0.87 FALSE 2 (0): 5318, (1): 3657
LICENSEHOSPLIC 1429 0.86 FALSE 2 (0): 7540, (1): 1405
LICENSEJC 1376 0.87 FALSE 2 (0): 5725, (1): 3273
LICENSECARF 1393 0.87 FALSE 2 (0): 7180, (1): 1801
LICENSECOA 1500 0.86 FALSE 2 (0): 7933, (1): 941
LICENSEDFCS 1436 0.86 FALSE 2 (0): 7428, (1): 1510
LICENSEDHHS 1546 0.85 FALSE 2 (0): 7534, (1): 1294
LICENSEMEDICARE 1502 0.86 FALSE 2 (0): 4467, (1): 4405
LICENSEMEDICAID 1466 0.86 FALSE 2 (1): 5743, (0): 3165
LICENSEOTHORG 1319 0.87 FALSE 2 (0): 8407, (1): 648
FACONLY 0 1.00 FALSE 3 (1): 7473, (3): 2209, (2): 692
IPSERV 0 1.00 FALSE 2 (0): 8386, (1): 1988
RCSERV 0 1.00 FALSE 2 (0): 8048, (1): 2326
OPSERV 0 1.00 FALSE 2 (1): 7871, (0): 2503
SRVCHAR 0 1.00 FALSE 2 (1): 9139, (0): 1235

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
CASEID 0 1.00 5187.50 2994.86 1 2594.25 5187.5 7780.75 10374 ▇▇▇▇▇
TOTALFAC 9682 0.07 3.93 2.97 2 2.00 3.0 5.00 27 ▇▁▁▁▁
IPTOTAL 8386 0.19 50.05 90.53 1 12.00 23.0 52.00 1506 ▇▁▁▁▁
IPSEXTOTM 8386 0.19 29.65 66.30 0 6.00 12.0 27.00 1157 ▇▁▁▁▁
IPSEXPERM 8386 0.19 52.62 17.46 0 42.00 51.0 61.00 100 ▁▃▇▃▁
IPSEXTOTF 8386 0.19 20.40 31.06 0 6.00 11.0 22.00 371 ▇▁▁▁▁
IPSEXPERF 8386 0.19 47.38 17.46 0 39.00 49.0 58.00 100 ▁▃▇▂▁
IPAGETOT017 8386 0.19 10.37 35.95 0 0.00 0.0 10.00 923 ▇▁▁▁▁
IPAGEPER017 8386 0.19 20.23 33.74 0 0.00 0.0 28.00 100 ▇▂▁▁▂
IPAGETOT1864 8386 0.19 33.99 77.34 0 4.00 14.0 30.00 1409 ▇▁▁▁▁
IPAGEPER1864 8386 0.19 61.69 36.82 0 33.75 75.0 93.00 100 ▅▁▂▃▇
IPAGETOT65 8386 0.19 5.69 13.29 0 0.00 2.0 7.00 238 ▇▁▁▁▁
IPAGEPER65 8386 0.19 18.08 28.21 0 0.00 7.0 20.00 100 ▇▁▁▁▁
IPETHTOTHISP 8386 0.19 3.56 15.93 0 0.00 0.0 1.00 338 ▇▁▁▁▁
IPETHPERHISP 8386 0.19 5.33 13.01 0 0.00 0.0 5.00 100 ▇▁▁▁▁
IPETHTOTNONHISP 8386 0.19 25.82 71.12 0 0.00 6.0 21.00 1168 ▇▁▁▁▁
IPETHPERNONHISP 8386 0.19 48.70 46.12 0 0.00 65.0 97.00 100 ▇▁▁▁▇
IPETHTOTUNK 8386 0.19 20.68 52.55 0 0.00 2.0 23.00 923 ▇▁▁▁▁
IPETHPERUNK 8386 0.19 45.97 49.13 0 0.00 4.0 100.00 100 ▇▁▁▁▇
IPRACETOTINDIAN 8386 0.19 0.21 1.62 0 0.00 0.0 0.00 40 ▇▁▁▁▁
IPRACEPERINDIAN 8386 0.19 0.42 2.68 0 0.00 0.0 0.00 50 ▇▁▁▁▁
IPRACETOTASIAN 8386 0.19 0.48 2.69 0 0.00 0.0 0.00 56 ▇▁▁▁▁
IPRACEPERASIAN 8386 0.19 0.69 2.70 0 0.00 0.0 0.00 50 ▇▁▁▁▁
IPRACETOTBLK 8386 0.19 7.94 28.70 0 0.00 0.0 3.00 457 ▇▁▁▁▁
IPRACEPERBLK 8386 0.19 10.35 17.84 0 0.00 0.0 15.00 100 ▇▁▁▁▁
IPRACETOTHAWPAC 8386 0.19 0.09 1.51 0 0.00 0.0 0.00 53 ▇▁▁▁▁
IPRACEPERHAWPAC 8386 0.19 0.14 2.72 0 0.00 0.0 0.00 85 ▇▁▁▁▁
IPRACETOTWHIT 8386 0.19 17.85 50.04 0 0.00 2.0 15.00 775 ▇▁▁▁▁
IPRACEPERWHIT 8386 0.19 37.33 39.93 0 0.00 20.5 78.00 100 ▇▁▂▂▃
IPRACETOTMR 8386 0.19 1.06 18.45 0 0.00 0.0 0.00 757 ▇▁▁▁▁
IPRACEPERMR 8386 0.19 1.42 8.26 0 0.00 0.0 0.00 100 ▇▁▁▁▁
IPRACETOTUNK 8386 0.19 22.41 49.67 0 0.00 6.5 25.00 923 ▇▁▁▁▁
IPRACEPERUNK 8386 0.19 49.66 48.47 0 0.00 27.0 100.00 100 ▇▁▁▁▇
IPLEGALTOTVOL 8386 0.19 20.69 32.01 0 5.00 12.0 25.00 522 ▇▁▁▁▁
IPLEGALPERVOL 8386 0.19 59.63 36.84 0 26.75 67.0 100.00 100 ▅▂▃▂▇
IPLEGALTOTNONFOREN 8386 0.19 19.00 49.95 0 0.00 4.0 16.00 923 ▇▁▁▁▁
IPLEGALPERNONFOREN 8386 0.19 31.67 32.98 0 0.00 20.0 55.00 100 ▇▂▂▂▂
IPLEGALTOTFOREN 8386 0.19 10.36 57.91 0 0.00 0.0 0.00 1506 ▇▁▁▁▁
IPLEGALPERFOREN 8386 0.19 8.70 24.68 0 0.00 0.0 0.00 100 ▇▁▁▁▁
IPBEDS 8386 0.19 57.13 89.25 1 18.00 31.0 60.00 1506 ▇▁▁▁▁
RCTOTAL 8048 0.22 26.12 34.13 1 8.00 15.0 30.00 427 ▇▁▁▁▁
RCSEXTOTM 8048 0.22 17.90 27.88 0 4.00 9.0 22.00 422 ▇▁▁▁▁
RCSEXPERM 8048 0.22 64.41 28.30 0 50.00 62.0 97.00 100 ▂▂▇▆▇
RCSEXTOTF 8048 0.22 8.23 12.62 0 0.00 4.0 10.00 159 ▇▁▁▁▁
RCSEXPERF 8048 0.22 35.59 28.30 0 3.00 38.0 50.00 100 ▇▇▇▂▂
RCAGETOT017 8048 0.22 13.71 25.79 0 0.00 0.0 17.00 360 ▇▁▁▁▁
RCAGEPER017 8048 0.22 41.63 46.95 0 0.00 0.0 100.00 100 ▇▁▁▁▆
RCAGETOT1864 8048 0.22 10.96 25.07 0 0.00 5.0 13.00 402 ▇▁▁▁▁
RCAGEPER1864 8048 0.22 52.52 44.61 0 0.00 67.0 100.00 100 ▇▁▁▁▇
RCAGETOT65 8048 0.22 1.46 6.69 0 0.00 0.0 0.00 186 ▇▁▁▁▁
RCAGEPER65 8048 0.22 5.85 15.99 0 0.00 0.0 0.00 100 ▇▁▁▁▁
RCETHTOTHISP 8048 0.22 1.88 5.14 0 0.00 0.0 1.00 60 ▇▁▁▁▁
RCETHPERHISP 8048 0.22 6.99 13.70 0 0.00 0.0 9.00 100 ▇▁▁▁▁
RCETHTOTNONHISP 8048 0.22 15.69 27.99 0 0.00 7.5 17.00 406 ▇▁▁▁▁
RCETHPERNONHISP 8048 0.22 63.08 42.72 0 0.00 87.0 100.00 100 ▅▁▁▂▇
RCETHTOTUNK 8048 0.22 8.55 21.53 0 0.00 0.0 7.00 320 ▇▁▁▁▁
RCETHPERUNK 8048 0.22 29.93 44.64 0 0.00 0.0 100.00 100 ▇▁▁▁▃
RCRACETOTINDIAN 8048 0.22 0.36 1.85 0 0.00 0.0 0.00 29 ▇▁▁▁▁
RCRACEPERINDIAN 8048 0.22 1.52 7.19 0 0.00 0.0 0.00 100 ▇▁▁▁▁
RCRACETOTASIAN 8048 0.22 0.17 0.74 0 0.00 0.0 0.00 13 ▇▁▁▁▁
RCRACEPERASIAN 8048 0.22 0.79 3.45 0 0.00 0.0 0.00 50 ▇▁▁▁▁
RCRACETOTBLK 8048 0.22 4.80 11.43 0 0.00 1.0 4.00 198 ▇▁▁▁▁
RCRACEPERBLK 8048 0.22 17.50 23.72 0 0.00 5.0 30.00 100 ▇▂▁▁▁
RCRACETOTHAWPAC 8048 0.22 0.09 0.93 0 0.00 0.0 0.00 24 ▇▁▁▁▁
RCRACEPERHAWPAC 8048 0.22 0.57 5.80 0 0.00 0.0 0.00 100 ▇▁▁▁▁
RCRACETOTWHIT 8048 0.22 9.93 18.98 0 0.00 5.0 11.00 359 ▇▁▁▁▁
RCRACEPERWHIT 8048 0.22 44.38 37.11 0 0.00 49.5 78.00 100 ▇▂▃▅▅
RCRACETOTMR 8048 0.22 0.79 3.10 0 0.00 0.0 0.00 80 ▇▁▁▁▁
RCRACEPERMR 8048 0.22 2.88 8.17 0 0.00 0.0 0.00 100 ▇▁▁▁▁
RCRACETOTUNK 8048 0.22 9.98 23.71 0 0.00 0.0 9.00 400 ▇▁▁▁▁
RCRACEPERUNK 8048 0.22 32.37 44.56 0 0.00 0.0 100.00 100 ▇▁▁▁▃
RCLEGALTOTVOL 8048 0.22 15.57 26.78 0 1.00 8.0 17.00 427 ▇▁▁▁▁
RCLEGALPERVOL 8048 0.22 66.39 42.78 0 11.00 100.0 100.00 100 ▃▁▁▁▇
RCLEGALTOTNONFOREN 8048 0.22 6.75 18.37 0 0.00 0.0 5.00 288 ▇▁▁▁▁
RCLEGALPERNONFOREN 8048 0.22 20.25 33.08 0 0.00 0.0 37.00 100 ▇▁▁▁▁
RCLEGALTOTFOREN 8048 0.22 3.80 15.67 0 0.00 0.0 0.00 336 ▇▁▁▁▁
RCLEGALPERFOREN 8048 0.22 13.36 29.38 0 0.00 0.0 0.00 100 ▇▁▁▁▁
RCBEDS 8048 0.22 29.26 40.20 1 8.00 16.0 34.00 713 ▇▁▁▁▁
OPTOTAL 2503 0.76 384.50 584.28 1 60.00 200.0 465.00 14332 ▇▁▁▁▁
OPSEXTOTM 2503 0.76 188.66 356.57 0 30.00 97.0 220.00 13375 ▇▁▁▁▁
OPSEXPERM 2503 0.76 49.31 14.60 0 42.00 49.0 55.00 100 ▁▂▇▁▁
OPSEXTOTF 2503 0.76 195.83 293.48 0 29.00 99.0 239.00 4791 ▇▁▁▁▁
OPSEXPERF 2503 0.76 50.69 14.60 0 45.00 51.0 58.00 100 ▁▂▇▂▁
OPAGETOT017 2503 0.76 105.56 240.11 0 0.00 35.0 115.00 5127 ▇▁▁▁▁
OPAGEPER017 2503 0.76 30.93 32.27 0 0.00 24.0 41.00 100 ▇▅▂▁▂
OPAGETOT1864 2503 0.76 248.71 414.88 0 24.00 112.0 295.00 8018 ▇▁▁▁▁
OPAGEPER1864 2503 0.76 61.57 30.97 0 48.00 68.0 86.00 100 ▅▁▅▇▇
OPAGETOT65 2503 0.76 30.23 112.20 0 0.00 8.0 26.50 6314 ▇▁▁▁▁
OPAGEPER65 2503 0.76 7.50 12.97 0 0.00 4.0 10.00 100 ▇▁▁▁▁
OPETHTOTHISP 2503 0.76 32.98 122.14 0 0.00 2.0 18.00 3320 ▇▁▁▁▁
OPETHPERHISP 2503 0.76 8.96 17.43 0 0.00 1.0 10.00 100 ▇▁▁▁▁
OPETHTOTNONHISP 2503 0.76 200.33 389.41 0 0.00 44.0 231.00 8594 ▇▁▁▁▁
OPETHPERNONHISP 2503 0.76 54.95 43.21 0 0.00 75.0 96.00 100 ▆▁▁▂▇
OPETHTOTUNK 2503 0.76 151.19 447.03 0 0.00 3.0 100.00 14332 ▇▁▁▁▁
OPETHPERUNK 2503 0.76 36.09 46.26 0 0.00 1.0 100.00 100 ▇▁▁▁▅
OPRACETOTINDIAN 2503 0.76 2.29 9.79 0 0.00 0.0 1.00 334 ▇▁▁▁▁
OPRACEPERINDIAN 2503 0.76 0.93 4.72 0 0.00 0.0 0.00 100 ▇▁▁▁▁
OPRACETOTASIAN 2503 0.76 3.53 26.89 0 0.00 0.0 1.00 1148 ▇▁▁▁▁
OPRACEPERASIAN 2503 0.76 0.81 4.34 0 0.00 0.0 0.00 100 ▇▁▁▁▁
OPRACETOTBLK 2503 0.76 44.09 138.19 0 0.00 1.0 24.00 2365 ▇▁▁▁▁
OPRACEPERBLK 2503 0.76 11.79 20.07 0 0.00 1.0 15.00 100 ▇▁▁▁▁
OPRACETOTHAWPAC 2503 0.76 1.37 16.29 0 0.00 0.0 0.00 567 ▇▁▁▁▁
OPRACEPERHAWPAC 2503 0.76 0.39 3.77 0 0.00 0.0 0.00 99 ▇▁▁▁▁
OPRACETOTWHIT 2503 0.76 149.76 343.79 0 0.00 16.0 160.00 12017 ▇▁▁▁▁
OPRACEPERWHIT 2503 0.76 40.28 38.80 0 0.00 40.0 80.00 100 ▇▁▂▂▅
OPRACETOTMR 2503 0.76 7.32 39.34 0 0.00 0.0 1.00 1470 ▇▁▁▁▁
OPRACEPERMR 2503 0.76 2.13 7.48 0 0.00 0.0 1.00 100 ▇▁▁▁▁
OPRACETOTUNK 2503 0.76 176.14 424.82 0 0.00 18.0 162.50 7482 ▇▁▁▁▁
OPRACEPERUNK 2503 0.76 43.67 47.03 0 0.00 12.0 100.00 100 ▇▁▁▁▆
OPLEGALTOTVOL 2503 0.76 313.24 536.21 0 25.00 133.0 378.00 14332 ▇▁▁▁▁
OPLEGALPERVOL 2503 0.76 82.01 34.49 0 87.00 100.0 100.00 100 ▂▁▁▁▇
OPLEGALTOTNONFOREN 2503 0.76 13.87 114.73 0 0.00 0.0 0.00 7141 ▇▁▁▁▁
OPLEGALPERNONFOREN 2503 0.76 3.75 12.49 0 0.00 0.0 0.00 100 ▇▁▁▁▁
OPLEGALTOTFOREN 2503 0.76 57.39 243.48 0 0.00 0.0 6.00 7482 ▇▁▁▁▁
OPLEGALPERFOREN 2503 0.76 14.24 32.28 0 0.00 0.0 3.00 100 ▇▁▁▁▁
PERCENTCP 3197 0.69 27.40 25.81 0 5.00 20.0 40.00 100 ▇▃▂▁▁
MHADMISSIONS 6 1.00 801.14 1835.69 0 91.00 480.0 786.00 60000 ▇▁▁▁▁
PERCENTVA 3478 0.66 5.60 15.87 0 0.00 1.0 5.00 100 ▇▁▁▁▁

Clean 2010 data

treat_cleaned_2010 <- treatments_2010 %>%
  select(starts_with("TREAT")) %>%
  pivot_longer(cols = everything(), names_to = "treatment", values_to = "count") %>%
  mutate(count = readr::parse_number(as.character(count))) %>%
  group_by(treatment) %>%
  summarise(mean(count, na.rm = TRUE))  %>%
  mutate(treatment = case_when(
    treatment == "TREATPSYCHOTHRPY" ~ "psychotherapy",
    treatment == "TREATFAMTHRPY" ~ "family therapy",
    treatment == "TREATGRPTHRPY" ~ "group therapy",
    treatment == "TREATCOGTHRPY" ~ "cognitive behavioral therapy",
    treatment == "TREATDIALTHRPY" ~ "dialectical behavior therapy",
    treatment == "TREATBEHAVMOD" ~ "behavior modification",
    treatment == "TREATDUALMHSA" ~ "integrated dual disorders treatment",
    treatment == "TREATTRAUMATHRPY" ~ "trauma therapy",
    treatment == "TREATACTVTYTHRPY" ~ "activity therapy",
    treatment == "TREATELECTRO" ~ "electroconvulsive therapy",
    treatment == "TREATTELEMEDINCE" ~ "telemedicine therapy",
    treatment == "TREATPSYCHOMED" ~ "psychotropic medication",
    treatment == "TREATOTH" ~ "mentalhealth treatment approach",
    treatment == "TREATMT" ~ "substanceuse treatment",
    TRUE ~ as.character(treatment)))
  
  treat_cleaned_2010
## # A tibble: 11 x 2
##    treatment                           `mean(count, na.rm = TRUE)`
##    <chr>                                                     <dbl>
##  1 activity therapy                                         0.515 
##  2 behavior modification                                    0.655 
##  3 cognitive behavioral therapy                             0.887 
##  4 integrated dual disorders treatment                      0.549 
##  5 electroconvulsive therapy                                0.0634
##  6 family therapy                                           0.675 
##  7 group therapy                                            0.852 
##  8 mentalhealth treatment approach                          0.0835
##  9 psychotropic medication                                  0.837 
## 10 psychotherapy                                            0.863 
## 11 telemedicine therapy                                     0.157