Project !

Author

Cynthia Wright

Quarto

Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see https://quarto.org.

Running Code

When you click the Render button a document will be generated that includes both content and the output of embedded code. You can embed code like this:

1 + 1
[1] 2

You can add options to executable code like this

[1] 4
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.2.1     ✔ readr     2.2.0
✔ forcats   1.0.1     ✔ stringr   1.6.0
✔ ggplot2   4.0.3     ✔ tibble    3.3.1
✔ lubridate 1.9.5     ✔ tidyr     1.3.2
✔ purrr     1.2.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(dplyr)
maltreatment <-read_csv("Maltreatment_Types_of_Victims_20260801.csv")
Rows: 54 Columns: 21
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr  (1): State
dbl (12): Sex Trafficking Only, Unknown Only, Medical Neglect Only Percent, ...
num  (8): Medical Neglect Only, Neglect Only, Other Only, Physical Abuse Onl...

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
head(maltreatment)
# A tibble: 6 × 21
  State `Medical Neglect Only` `Neglect Only` `Other Only` `Physical Abuse Only`
  <chr>                  <dbl>          <dbl>        <dbl>                 <dbl>
1 Alab…                     49           3380           NA                  5114
2 Alas…                     37           1445           NA                   111
3 Ariz…                     NA          11332           NA                   682
4 Arka…                   1279           3421            1                  1286
5 Cali…                     NA          50799          117                  2161
6 Colo…                     80           9517           NA                   854
# ℹ 16 more variables: `Psychological Maltreatment Only` <dbl>,
#   `Sexual Abuse Only` <dbl>, `Sex Trafficking Only` <dbl>,
#   `Unknown Only` <dbl>, `Multiple Maltreatment Types` <dbl>,
#   `Total Victims` <dbl>, `Medical Neglect Only Percent` <dbl>,
#   `Neglect Only Percent` <dbl>, `Other Only Percent` <dbl>,
#   `Physical Abuse Only Percent` <dbl>,
#   `Psychological Maltreatment Only Percent` <dbl>, …
tail(maltreatment)
# A tibble: 6 × 21
  State `Medical Neglect Only` `Neglect Only` `Other Only` `Physical Abuse Only`
  <chr>                  <dbl>          <dbl>        <dbl>                 <dbl>
1 Wash…                     NA           2831           NA                   569
2 West…                     NA           1173           NA                   902
3 Wisc…                     NA           2802           NA                   546
4 Wyom…                      2            655           NA                    13
5 Nati…                   5614         399992        17614                 67678
6 Repo…                     36             52           21                    52
# ℹ 16 more variables: `Psychological Maltreatment Only` <dbl>,
#   `Sexual Abuse Only` <dbl>, `Sex Trafficking Only` <dbl>,
#   `Unknown Only` <dbl>, `Multiple Maltreatment Types` <dbl>,
#   `Total Victims` <dbl>, `Medical Neglect Only Percent` <dbl>,
#   `Neglect Only Percent` <dbl>, `Other Only Percent` <dbl>,
#   `Physical Abuse Only Percent` <dbl>,
#   `Psychological Maltreatment Only Percent` <dbl>, …
str(maltreatment)
spc_tbl_ [54 × 21] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
 $ State                                  : chr [1:54] "Alabama" "Alaska" "Arizona" "Arkansas" ...
 $ Medical Neglect Only                   : num [1:54] 49 37 NA 1279 NA ...
 $ Neglect Only                           : num [1:54] 3380 1445 11332 3421 50799 ...
 $ Other Only                             : num [1:54] NA NA NA 1 117 ...
 $ Physical Abuse Only                    : num [1:54] 5114 111 682 1286 2161 ...
 $ Psychological Maltreatment Only        : num [1:54] 16 327 1 25 2115 ...
 $ Sexual Abuse Only                      : num [1:54] 1828 183 389 1415 2264 ...
 $ Sex Trafficking Only                   : num [1:54] 3 1 NA NA NA NA NA NA 14 NA ...
 $ Unknown Only                           : num [1:54] NA NA NA NA NA 9 NA NA NA NA ...
 $ Multiple Maltreatment Types            : num [1:54] 1287 955 443 995 6659 ...
 $ Total Victims                          : num [1:54] 11677 3059 12847 8422 64115 ...
 $ Medical Neglect Only Percent           : num [1:54] 0.4 1.2 NA 15.2 NA 0.7 1.1 NA NA 1.9 ...
 $ Neglect Only Percent                   : num [1:54] 28.9 47.2 88.2 40.6 79.2 77.7 58.6 25.1 80.3 39.2 ...
 $ Other Only Percent                     : num [1:54] NA NA NA 0 0.2 NA NA 9.6 NA 24.9 ...
 $ Physical Abuse Only Percent            : num [1:54] 43.8 3.6 5.3 15.3 3.4 7 2.1 12.9 9.4 5.3 ...
 $ Psychological Maltreatment Only Percent: num [1:54] 0.1 10.7 0 0.3 3.3 1 7.4 32.4 NA 0.5 ...
 $ Sexual Abuse Only Percent              : num [1:54] 15.7 6 3 16.8 3.5 8.1 2.3 9.7 2.4 7.2 ...
 $ Sex Trafficking Only Percent           : num [1:54] 0 0 NA NA NA NA NA NA 0.8 NA ...
 $ Unknown Only Percent                   : num [1:54] NA NA NA NA NA 0.1 NA NA NA NA ...
 $ Multiple Maltreatment Types Percent    : num [1:54] 11 31.2 3.4 11.8 10.4 5.5 28.5 10.3 7.1 21.1 ...
 $ Total Victims Percent                  : num [1:54] 100 100 100 100 100 100 100 100 100 100 ...
 - attr(*, "spec")=
  .. cols(
  ..   State = col_character(),
  ..   `Medical Neglect Only` = col_number(),
  ..   `Neglect Only` = col_number(),
  ..   `Other Only` = col_number(),
  ..   `Physical Abuse Only` = col_number(),
  ..   `Psychological Maltreatment Only` = col_number(),
  ..   `Sexual Abuse Only` = col_number(),
  ..   `Sex Trafficking Only` = col_double(),
  ..   `Unknown Only` = col_double(),
  ..   `Multiple Maltreatment Types` = col_number(),
  ..   `Total Victims` = col_number(),
  ..   `Medical Neglect Only Percent` = col_double(),
  ..   `Neglect Only Percent` = col_double(),
  ..   `Other Only Percent` = col_double(),
  ..   `Physical Abuse Only Percent` = col_double(),
  ..   `Psychological Maltreatment Only Percent` = col_double(),
  ..   `Sexual Abuse Only Percent` = col_double(),
  ..   `Sex Trafficking Only Percent` = col_double(),
  ..   `Unknown Only Percent` = col_double(),
  ..   `Multiple Maltreatment Types Percent` = col_double(),
  ..   `Total Victims Percent` = col_double()
  .. )
 - attr(*, "problems")=<pointer: 0x7fe883050ea0> 
maltreatment_victims <- maltreatment |>
  
  group_by(State) |>
  
  summarize(
    `Total Victims` = mean(`Total Victims`),
    `Medical Neglect Only` = mean(`Medical Neglect Only`),
    `Neglect Only` = mean(`Neglect Only`),
  ) 

print(maltreatment_victims)
# A tibble: 54 × 4
   State                `Total Victims` `Medical Neglect Only` `Neglect Only`
   <chr>                          <dbl>                  <dbl>          <dbl>
 1 Alabama                        11677                     49           3380
 2 Alaska                          3059                     37           1445
 3 Arizona                        12847                     NA          11332
 4 Arkansas                        8422                   1279           3421
 5 California                     64115                     NA          50799
 6 Colorado                       12246                     80           9517
 7 Connecticut                     8042                     87           4709
 8 Delaware                        1248                     NA            313
 9 District of Columbia            1857                     NA           1492
10 Florida                        32915                    616          12893
# ℹ 44 more rows
plot(maltreatment_victims$`Total Victims`, maltreatment_victims$`Medical Neglect Only`, 
     col =   "blue", pch = 16, 
     main = "Scatter Plot", xlab = "Total Victims", ylab = "Medical Neglect")

The echo: false option disables the printing of code (only output is displayed).

p1 <- maltreatment_victims |>
  ggplot(aes(x= `Medical Neglect Only`, fill= State)) +
  geom_histogram(position="identity")+
  scale_fill_discrete(name = "Medical Neglect Only") + geom_histogram(bins = 15)

print(p1)
`stat_bin()` using `bins = 30`. Pick better value `binwidth`.
Warning: Removed 16 rows containing non-finite outside the scale range (`stat_bin()`).
Removed 16 rows containing non-finite outside the scale range (`stat_bin()`).

p2 <- maltreatment_victims |>
  ggplot(aes(x= `Neglect Only`, fill= State)) +
  geom_histogram(position="identity") +
  scale_fill_discrete(name = "Neglect Only") + geom_histogram(bins = 15)


print(p2)
`stat_bin()` using `bins = 30`. Pick better value `binwidth`.