cis-ds / Discussion

Public discussion
10 stars 15 forks source link

02-reorder-graph-example #181

Closed bensoltoff closed 3 years ago

bensoltoff commented 3 years ago

Post your reproducible example here

margotbarranco commented 3 years ago
## Copy the code below to generate a reproducible example
## using the reprex package. Once you generate it, post it on
## https://github.com/uc-cfss/Discussion/issues/181

library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case   year month   day location summary fatalities injured total_victims
#>    <chr> <dbl> <chr> <int> <chr>    <chr>        <dbl>   <dbl>         <dbl>
#>  1 Dayt…  2019 Aug       4 Dayton,… "PENDI…          9      27            36
#>  2 El P…  2019 Aug       3 El Paso… "PENDI…         20      26            46
#>  3 Gilr…  2019 Jul      28 Gilroy,… "Santi…          3      12            15
#>  4 Virg…  2019 May      31 Virgini… "DeWay…         12       4            16
#>  5 Harr…  2019 Feb      15 Aurora,… "Gary …          5       6            11
#>  6 Penn…  2019 Jan      24 State C… "Jorda…          3       1             4
#>  7 SunT…  2019 Jan      23 Sebring… "Zephe…          5       0             5
#>  8 Merc…  2018 Nov      19 Chicago… "Juan …          3       0             3
#>  9 Thou…  2018 Nov       7 Thousan… "Ian D…         12      22            34
#> 10 Tree…  2018 Oct      27 Pittsbu… "Rober…         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-02-18 by the reprex package (v0.3.0)

jthedu commented 3 years ago
## Copy the code below to generate a reproducible example
## using the reprex package. Once you generate it, post it on
## https://github.com/uc-cfss/Discussion/issues/181

library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case   year month   day location summary fatalities injured total_victims
#>    <chr> <dbl> <chr> <int> <chr>    <chr>        <dbl>   <dbl>         <dbl>
#>  1 Dayt…  2019 Aug       4 Dayton,… "PENDI…          9      27            36
#>  2 El P…  2019 Aug       3 El Paso… "PENDI…         20      26            46
#>  3 Gilr…  2019 Jul      28 Gilroy,… "Santi…          3      12            15
#>  4 Virg…  2019 May      31 Virgini… "DeWay…         12       4            16
#>  5 Harr…  2019 Feb      15 Aurora,… "Gary …          5       6            11
#>  6 Penn…  2019 Jan      24 State C… "Jorda…          3       1             4
#>  7 SunT…  2019 Jan      23 Sebring… "Zephe…          5       0             5
#>  8 Merc…  2018 Nov      19 Chicago… "Juan …          3       0             3
#>  9 Thou…  2018 Nov       7 Thousan… "Ian D…         12      22            34
#> 10 Tree…  2018 Oct      27 Pittsbu… "Rober…         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-02-18 by the reprex package (v0.3.0)

chidatlam commented 3 years ago
## Copy the code below to generate a reproducible example
## using the reprex package. Once you generate it, post it on
## https://github.com/uc-cfss/Discussion/issues/181

library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case   year month   day location summary fatalities injured total_victims
#>    <chr> <dbl> <chr> <int> <chr>    <chr>        <dbl>   <dbl>         <dbl>
#>  1 Dayt…  2019 Aug       4 Dayton,… "PENDI…          9      27            36
#>  2 El P…  2019 Aug       3 El Paso… "PENDI…         20      26            46
#>  3 Gilr…  2019 Jul      28 Gilroy,… "Santi…          3      12            15
#>  4 Virg…  2019 May      31 Virgini… "DeWay…         12       4            16
#>  5 Harr…  2019 Feb      15 Aurora,… "Gary …          5       6            11
#>  6 Penn…  2019 Jan      24 State C… "Jorda…          3       1             4
#>  7 SunT…  2019 Jan      23 Sebring… "Zephe…          5       0             5
#>  8 Merc…  2018 Nov      19 Chicago… "Juan …          3       0             3
#>  9 Thou…  2018 Nov       7 Thousan… "Ian D…         12      22            34
#> 10 Tree…  2018 Oct      27 Pittsbu… "Rober…         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-02-18 by the reprex package (v0.3.0)

vinsgromeo commented 3 years ago
## Copy the code below to generate a reproducible example
## using the reprex package. Once you generate it, post it on
## https://github.com/uc-cfss/Discussion/issues/181

library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case   year month   day location summary fatalities injured total_victims
#>    <chr> <dbl> <chr> <int> <chr>    <chr>        <dbl>   <dbl>         <dbl>
#>  1 Dayt…  2019 Aug       4 Dayton,… "PENDI…          9      27            36
#>  2 El P…  2019 Aug       3 El Paso… "PENDI…         20      26            46
#>  3 Gilr…  2019 Jul      28 Gilroy,… "Santi…          3      12            15
#>  4 Virg…  2019 May      31 Virgini… "DeWay…         12       4            16
#>  5 Harr…  2019 Feb      15 Aurora,… "Gary …          5       6            11
#>  6 Penn…  2019 Jan      24 State C… "Jorda…          3       1             4
#>  7 SunT…  2019 Jan      23 Sebring… "Zephe…          5       0             5
#>  8 Merc…  2018 Nov      19 Chicago… "Juan …          3       0             3
#>  9 Thou…  2018 Nov       7 Thousan… "Ian D…         12      22            34
#> 10 Tree…  2018 Oct      27 Pittsbu… "Rober…         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-02-18 by the reprex package (v0.3.0)

claramfong commented 3 years ago
## Copy the code below to generate a reproducible example
## using the reprex package. Once you generate it, post it on
## https://github.com/uc-cfss/Discussion/issues/181

library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case   year month   day location summary fatalities injured total_victims
#>    <chr> <dbl> <chr> <int> <chr>    <chr>        <dbl>   <dbl>         <dbl>
#>  1 Dayt…  2019 Aug       4 Dayton,… "PENDI…          9      27            36
#>  2 El P…  2019 Aug       3 El Paso… "PENDI…         20      26            46
#>  3 Gilr…  2019 Jul      28 Gilroy,… "Santi…          3      12            15
#>  4 Virg…  2019 May      31 Virgini… "DeWay…         12       4            16
#>  5 Harr…  2019 Feb      15 Aurora,… "Gary …          5       6            11
#>  6 Penn…  2019 Jan      24 State C… "Jorda…          3       1             4
#>  7 SunT…  2019 Jan      23 Sebring… "Zephe…          5       0             5
#>  8 Merc…  2018 Nov      19 Chicago… "Juan …          3       0             3
#>  9 Thou…  2018 Nov       7 Thousan… "Ian D…         12      22            34
#> 10 Tree…  2018 Oct      27 Pittsbu… "Rober…         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-02-18 by the reprex package (v0.3.0)

deblnia commented 3 years ago
## Copy the code below to generate a reproducible example
## using the reprex package. Once you generate it, post it on
## https://github.com/uc-cfss/Discussion/issues/181

library(tidyverse)
#> Warning: package 'ggplot2' was built under R version 3.6.2
#> Warning: package 'tibble' was built under R version 3.6.2
#> Warning: package 'tidyr' was built under R version 3.6.2
#> Warning: package 'purrr' was built under R version 3.6.2
#> Warning: package 'dplyr' was built under R version 3.6.2

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case   year month   day location summary fatalities injured total_victims
#>    <chr> <dbl> <chr> <int> <chr>    <chr>        <dbl>   <dbl>         <dbl>
#>  1 Dayt…  2019 Aug       4 Dayton,… "PENDI…          9      27            36
#>  2 El P…  2019 Aug       3 El Paso… "PENDI…         20      26            46
#>  3 Gilr…  2019 Jul      28 Gilroy,… "Santi…          3      12            15
#>  4 Virg…  2019 May      31 Virgini… "DeWay…         12       4            16
#>  5 Harr…  2019 Feb      15 Aurora,… "Gary …          5       6            11
#>  6 Penn…  2019 Jan      24 State C… "Jorda…          3       1             4
#>  7 SunT…  2019 Jan      23 Sebring… "Zephe…          5       0             5
#>  8 Merc…  2018 Nov      19 Chicago… "Juan …          3       0             3
#>  9 Thou…  2018 Nov       7 Thousan… "Ian D…         12      22            34
#> 10 Tree…  2018 Oct      27 Pittsbu… "Rober…         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-02-18 by the reprex package (v0.3.0)

msoba22 commented 3 years ago
library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case   year month   day location summary fatalities injured total_victims
#>    <chr> <dbl> <chr> <int> <chr>    <chr>        <dbl>   <dbl>         <dbl>
#>  1 Dayt~  2019 Aug       4 Dayton,~ "PENDI~          9      27            36
#>  2 El P~  2019 Aug       3 El Paso~ "PENDI~         20      26            46
#>  3 Gilr~  2019 Jul      28 Gilroy,~ "Santi~          3      12            15
#>  4 Virg~  2019 May      31 Virgini~ "DeWay~         12       4            16
#>  5 Harr~  2019 Feb      15 Aurora,~ "Gary ~          5       6            11
#>  6 Penn~  2019 Jan      24 State C~ "Jorda~          3       1             4
#>  7 SunT~  2019 Jan      23 Sebring~ "Zephe~          5       0             5
#>  8 Merc~  2018 Nov      19 Chicago~ "Juan ~          3       0             3
#>  9 Thou~  2018 Nov       7 Thousan~ "Ian D~         12      22            34
#> 10 Tree~  2018 Oct      27 Pittsbu~ "Rober~         11       6            17
#> # ... with 104 more rows, and 5 more variables: location_type <chr>,
#> #   male <lgl>, age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>
#> # A tibble: 114 x 14
#>    case   year month   day location summary fatalities injured total_victims
#>    <chr> <dbl> <chr> <int> <chr>    <chr>        <dbl>   <dbl>         <dbl>
#>  1 Dayt…  2019 Aug       4 Dayton,… "PENDI…          9      27            36
#>  2 El P…  2019 Aug       3 El Paso… "PENDI…         20      26            46
#>  3 Gilr…  2019 Jul      28 Gilroy,… "Santi…          3      12            15
#>  4 Virg…  2019 May      31 Virgini… "DeWay…         12       4            16
#>  5 Harr…  2019 Feb      15 Aurora,… "Gary …          5       6            11
#>  6 Penn…  2019 Jan      24 State C… "Jorda…          3       1             4
#>  7 SunT…  2019 Jan      23 Sebring… "Zephe…          5       0             5
#>  8 Merc…  2018 Nov      19 Chicago… "Juan …          3       0             3
#>  9 Thou…  2018 Nov       7 Thousan… "Ian D…         12      22            34
#> 10 Tree…  2018 Oct      27 Pittsbu… "Rober…         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-02-18 by the reprex package (v1.0.0)

liu15611 commented 3 years ago
library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case   year month   day location summary fatalities injured total_victims
#>    <chr> <dbl> <chr> <int> <chr>    <chr>        <dbl>   <dbl>         <dbl>
#>  1 Dayt…  2019 Aug       4 Dayton,… "PENDI…          9      27            36
#>  2 El P…  2019 Aug       3 El Paso… "PENDI…         20      26            46
#>  3 Gilr…  2019 Jul      28 Gilroy,… "Santi…          3      12            15
#>  4 Virg…  2019 May      31 Virgini… "DeWay…         12       4            16
#>  5 Harr…  2019 Feb      15 Aurora,… "Gary …          5       6            11
#>  6 Penn…  2019 Jan      24 State C… "Jorda…          3       1             4
#>  7 SunT…  2019 Jan      23 Sebring… "Zephe…          5       0             5
#>  8 Merc…  2018 Nov      19 Chicago… "Juan …          3       0             3
#>  9 Thou…  2018 Nov       7 Thousan… "Ian D…         12      22            34
#> 10 Tree…  2018 Oct      27 Pittsbu… "Rober…         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-02-18 by the reprex package (v0.3.0)

bensoltoff commented 3 years ago
## Copy the code below to generate a reproducible example
## using the reprex package. Once you generate it, post it on
## https://github.com/uc-cfss/Discussion/issues/181

library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case   year month   day location summary fatalities injured total_victims
#>    <chr> <dbl> <chr> <int> <chr>    <chr>        <dbl>   <dbl>         <dbl>
#>  1 Dayt…  2019 Aug       4 Dayton,… "PENDI…          9      27            36
#>  2 El P…  2019 Aug       3 El Paso… "PENDI…         20      26            46
#>  3 Gilr…  2019 Jul      28 Gilroy,… "Santi…          3      12            15
#>  4 Virg…  2019 May      31 Virgini… "DeWay…         12       4            16
#>  5 Harr…  2019 Feb      15 Aurora,… "Gary …          5       6            11
#>  6 Penn…  2019 Jan      24 State C… "Jorda…          3       1             4
#>  7 SunT…  2019 Jan      23 Sebring… "Zephe…          5       0             5
#>  8 Merc…  2018 Nov      19 Chicago… "Juan …          3       0             3
#>  9 Thou…  2018 Nov       7 Thousan… "Ian D…         12      22            34
#> 10 Tree…  2018 Oct      27 Pittsbu… "Rober…         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-02-18 by the reprex package (v0.3.0)

nearridge commented 3 years ago
library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case   year month   day location summary fatalities injured total_victims
#>    <chr> <dbl> <chr> <int> <chr>    <chr>        <dbl>   <dbl>         <dbl>
#>  1 Dayt…  2019 Aug       4 Dayton,… "PENDI…          9      27            36
#>  2 El P…  2019 Aug       3 El Paso… "PENDI…         20      26            46
#>  3 Gilr…  2019 Jul      28 Gilroy,… "Santi…          3      12            15
#>  4 Virg…  2019 May      31 Virgini… "DeWay…         12       4            16
#>  5 Harr…  2019 Feb      15 Aurora,… "Gary …          5       6            11
#>  6 Penn…  2019 Jan      24 State C… "Jorda…          3       1             4
#>  7 SunT…  2019 Jan      23 Sebring… "Zephe…          5       0             5
#>  8 Merc…  2018 Nov      19 Chicago… "Juan …          3       0             3
#>  9 Thou…  2018 Nov       7 Thousan… "Ian D…         12      22            34
#> 10 Tree…  2018 Oct      27 Pittsbu… "Rober…         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-02-18 by the reprex package (v0.3.0)

lisettegonzalez commented 3 years ago
## Copy the code below to generate a reproducible example
## using the reprex package. Once you generate it, post it on
## https://github.com/uc-cfss/Discussion/issues/181

library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case   year month   day location summary fatalities injured total_victims
#>    <chr> <dbl> <chr> <int> <chr>    <chr>        <dbl>   <dbl>         <dbl>
#>  1 Dayt…  2019 Aug       4 Dayton,… "PENDI…          9      27            36
#>  2 El P…  2019 Aug       3 El Paso… "PENDI…         20      26            46
#>  3 Gilr…  2019 Jul      28 Gilroy,… "Santi…          3      12            15
#>  4 Virg…  2019 May      31 Virgini… "DeWay…         12       4            16
#>  5 Harr…  2019 Feb      15 Aurora,… "Gary …          5       6            11
#>  6 Penn…  2019 Jan      24 State C… "Jorda…          3       1             4
#>  7 SunT…  2019 Jan      23 Sebring… "Zephe…          5       0             5
#>  8 Merc…  2018 Nov      19 Chicago… "Juan …          3       0             3
#>  9 Thou…  2018 Nov       7 Thousan… "Ian D…         12      22            34
#> 10 Tree…  2018 Oct      27 Pittsbu… "Rober…         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-02-18 by the reprex package (v0.3.0)

mnjones323 commented 3 years ago
library(tidyverse)
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case   year month   day location summary fatalities injured total_victims
#>    <chr> <dbl> <chr> <int> <chr>    <chr>        <dbl>   <dbl>         <dbl>
#>  1 Dayt…  2019 Aug       4 Dayton,… "PENDI…          9      27            36
#>  2 El P…  2019 Aug       3 El Paso… "PENDI…         20      26            46
#>  3 Gilr…  2019 Jul      28 Gilroy,… "Santi…          3      12            15
#>  4 Virg…  2019 May      31 Virgini… "DeWay…         12       4            16
#>  5 Harr…  2019 Feb      15 Aurora,… "Gary …          5       6            11
#>  6 Penn…  2019 Jan      24 State C… "Jorda…          3       1             4
#>  7 SunT…  2019 Jan      23 Sebring… "Zephe…          5       0             5
#>  8 Merc…  2018 Nov      19 Chicago… "Juan …          3       0             3
#>  9 Thou…  2018 Nov       7 Thousan… "Ian D…         12      22            34
#> 10 Tree…  2018 Oct      27 Pittsbu… "Rober…         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-02-18 by the reprex package (v0.3.0)

bensoltoff commented 3 years ago
## Copy the code below to generate a reproducible example
## using the reprex package. Once you generate it, post it on
## https://github.com/uc-cfss/Discussion/issues/181

library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case   year month   day location summary fatalities injured total_victims
#>    <chr> <dbl> <chr> <int> <chr>    <chr>        <dbl>   <dbl>         <dbl>
#>  1 Dayt…  2019 Aug       4 Dayton,… "PENDI…          9      27            36
#>  2 El P…  2019 Aug       3 El Paso… "PENDI…         20      26            46
#>  3 Gilr…  2019 Jul      28 Gilroy,… "Santi…          3      12            15
#>  4 Virg…  2019 May      31 Virgini… "DeWay…         12       4            16
#>  5 Harr…  2019 Feb      15 Aurora,… "Gary …          5       6            11
#>  6 Penn…  2019 Jan      24 State C… "Jorda…          3       1             4
#>  7 SunT…  2019 Jan      23 Sebring… "Zephe…          5       0             5
#>  8 Merc…  2018 Nov      19 Chicago… "Juan …          3       0             3
#>  9 Thou…  2018 Nov       7 Thousan… "Ian D…         12      22            34
#> 10 Tree…  2018 Oct      27 Pittsbu… "Rober…         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-02-18 by the reprex package (v0.3.0)

reillyoflaherty commented 3 years ago
# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#>                                              case year month day
#> 1          Dayton entertainment district shooting 2019   Aug   4
#> 2                   El Paso Walmart mass shooting 2019   Aug   3
#> 3                 Gilroy garlic festival shooting 2019   Jul  28
#> 4      Virginia Beach municipal building shooting 2019   May  31
#> 5              Harry Pratt Co. warehouse shooting 2019   Feb  15
#> 6                 Pennsylvania hotel bar shooting 2019   Jan  24
#> 7                          SunTrust bank shooting 2019   Jan  23
#> 8                         Mercy Hospital shooting 2018   Nov  19
#> 9                Thousand Oaks nightclub shooting 2018   Nov   7
#> 10                Tree of Life synagogue shooting 2018   Oct  27
#> 11                    Rite Aid warehouse shooting 2018   Sep  20
#> 12                          T&T Trucking shooting 2018   Sep  12
#> 13                    Fifth Third Center shooting 2018   Sep   6
#> 14                       Capital Gazette shooting 2018   Jun  28
#> 15                  Santa Fe High School shooting 2018   May  18
#> 16                          Waffle House shooting 2018   Apr  22
#> 17              Yountville veterans home shooting 2018   Mar   9
#> 18  Marjory Stoneman Douglas High School shooting 2018   Feb  14
#> 19                  Pennsylvania carwash shooting 2018   Jan  28
#> 20                   Rancho Tehama shooting spree 2017   Nov  14
#> 21            Texas First Baptist Church massacre 2017   Nov   5
#> 22            Walmart shooting in suburban Denver 2017   Nov   1
#> 23                Edgewood businees park shooting 2017   Oct  18
#> 24                       Las Vegas Strip massacre 2017   Oct   1
#> 25                     San Francisco UPS shooting 2017   Jun  14
#> 26              Pennsylvania supermarket shooting 2017   Jun   7
#> 27           Florida awning manufacturer shooting 2017   Jun   5
#> 28               Rural Ohio nursing home shooting 2017   May  12
#> 29                       Fresno downtown shooting 2017   Apr  18
#> 30               Fort Lauderdale airport shooting 2017   Jan   6
#> 31                          Cascade Mall shooting 2016   Sep  23
#> 32                    Baton Rouge police shooting 2016   Jul  17
#> 33                         Dallas police shooting 2016   Jul   7
#> 34                     Orlando nightclub massacre 2016   Jun  12
#> 35                 Excel Industries mass shooting 2016   Feb  25
#> 36                       Kalamazoo shooting spree 2016   Feb  20
#> 37                   San Bernardino mass shooting 2015   Dec   2
#> 38                      Planned Parenthood clinic 2015   Nov  27
#> 39              Colorado Springs shooting rampage 2015   Oct  31
#> 40              Umpqua Community College shooting 2015   Oct   1
#> 41        Chattanooga military recruitment center 2015   Jul  16
#> 42                     Charleston Church Shooting 2015   Jun  17
#> 43                  Trestle Trail bridge shooting 2015   Jun  11
#> 44       Marysville-Pilchuck High School shooting 2014   Oct  24
#> 45                         Isla Vista mass murder 2014   May  23
#> 46                           Fort Hood shooting 2 2014   Apr   3
#> 47                        Alturas tribal shooting 2014   Feb  20
#> 48                  Washington Navy Yard shooting 2013   Sep  16
#> 49                     Hialeah apartment shooting 2013   Jul  26
#> 50                           Santa Monica rampage 2013   Jun   7
#> 51            Pinewood Village Apartment shooting 2013   Apr  21
#> 52                        Mohawk Valley shootings 2013   Mar  13
#> 53                 Sandy Hook Elementary massacre 2012   Dec  14
#> 54                Accent Signage Systems shooting 2012   Sep  27
#> 55                           Sikh temple shooting 2012   Aug   5
#> 56                        Aurora theater shooting 2012   Jul  20
#> 57                          Seattle cafe shooting 2012   May  20
#> 58                      Oikos University killings 2012   Apr   2
#> 59                  Su Jung Health Sauna shooting 2012   Feb  21
#> 60                            Seal Beach shooting 2011   Oct  12
#> 61                                  IHOP shooting 2011   Sep   6
#> 62                                Tucson shooting 2011   Jan   8
#> 63             Hartford Beer Distributor shooting 2010   Aug   3
#> 64                    Coffee shop police killings 2009   Nov  29
#> 65                             Fort Hood massacre 2009   Nov   5
#> 66                           Binghamton shootings 2009   Apr   3
#> 67                 Carthage nursing home shooting 2009   Mar  29
#> 68                     Atlantis Plastics shooting 2008   Jun  25
#> 69          Northern Illinois University shooting 2008   Feb  14
#> 70                 Kirkwood City Council shooting 2008   Feb   7
#> 71                        Westroads Mall shooting 2007   Dec   5
#> 72                               Crandon shooting 2007   Oct   7
#> 73                         Virginia Tech massacre 2007   Apr  16
#> 74                        Trolley Square shooting 2007   Feb  12
#> 75                          Amish school shooting 2006   Oct   2
#> 76                          Capitol Hill massacre 2006   Mar  25
#> 77                        Goleta postal shootings 2006   Jan  30
#> 78                              Red Lake massacre 2005   Mar  21
#> 79                  Living Church of God shooting 2005   Mar  12
#> 80                       Damageplan show shooting 2004   Dec   8
#> 81                       Lockheed Martin shooting 2003   Jul   8
#> 82                              Navistar shooting 2001   Feb   5
#> 83                             Wakefield massacre 2000   Dec  26
#> 84                                 Hotel shooting 1999   Dec  30
#> 85                                 Xerox killings 1999   Nov   2
#> 86               Wedgwood Baptist Church shooting 1999   Sep  15
#> 87             Atlanta day trading spree killings 1999   Jul  29
#> 88                 Columbine High School massacre 1999   Apr  20
#> 89                  Thurston High School shooting 1998   May  21
#> 90                Westside Middle School killings 1998   Mar  24
#> 91                   Connecticut Lottery shooting 1998   Mar   6
#> 92             Caltrans maintenance yard shooting 1997   Dec  18
#> 93                   R.E. Phelon Company shooting 1997   Sep  15
#> 94               Fort Lauderdale revenge shooting 1996   Feb   9
#> 95                Walter Rossler Company massacre 1995   Apr   3
#> 96                        Air Force base shooting 1994   Jun  20
#> 97                     Chuck E. Cheese's killings 1993   Dec  14
#> 98                 Long Island Rail Road massacre 1993   Dec   7
#> 99                               Luigi's shooting 1993   Aug   6
#> 100               101 California Street shootings 1993   Jul   1
#> 101                         Watkins Glen killings 1992   Oct  15
#> 102                Lindhurst High School shooting 1992   May   1
#> 103                    Royal Oak postal shootings 1991   Nov  14
#> 104                   University of Iowa shooting 1991   Nov   1
#> 105                               Luby's massacre 1991   Oct  16
#> 106                                 GMAC massacre 1990   Jun  18
#> 107                     Standard Gravure shooting 1989   Sep  14
#> 108                  Stockton schoolyard shooting 1989   Jan  17
#> 109                                  ESL shooting 1988   Feb  16
#> 110               Shopping centers spree killings 1987   Apr  23
#> 111         United States Postal Service shooting 1986   Aug  20
#> 112                San Ysidro McDonald's massacre 1984   Jul  18
#> 113                     Dallas nightclub shooting 1984   Jun  29
#> 114                         Welding shop shooting 1982   Aug  20
#>                                 location
#> 1                             Dayton, OH
#> 2                            El Paso, TX
#> 3                             Gilroy, CA
#> 4                     Virginia Beach, VA
#> 5                             Aurora, IL
#> 6                      State College, PA
#> 7                            Sebring, FL
#> 8                            Chicago, IL
#> 9                      Thousand Oaks, CA
#> 10                        Pittsburgh, PA
#> 11                          Perryman, MD
#> 12                       Bakersfield, CA
#> 13                        Cincinnati, OH
#> 14                         Annapolis, MD
#> 15                          Santa Fe, TX
#> 16                         Nashville, TN
#> 17                        Yountville, CA
#> 18                          Parkland, FL
#> 19                          Melcroft, PA
#> 20                     Rancho Tehama, CA
#> 21                Sutherland Springs, TX
#> 22                          Thornton, CO
#> 23                          Edgewood, MD
#> 24                         Las Vegas, NV
#> 25                     San Francisco, CA
#> 26             Tunkhannock, Pennsylvania
#> 27                      Orlando, Florida
#> 28                    Kirkersville, Ohio
#> 29                    Fresno, California
#> 30              Fort Lauderdale, Florida
#> 31                Burlington, Washington
#> 32                 Baton Rouge, Lousiana
#> 33                         Dallas, Texas
#> 34                      Orlando, Florida
#> 35                       Hesston, Kansas
#> 36            Kalamazoo County, Michigan
#> 37            San Bernardino, California
#> 38            Colorado Springs, Colorado
#> 39            Colorado Springs, Colorado
#> 40                      Roseburg, Oregon
#> 41                Chattanooga, Tennessee
#> 42            Charleston, South Carolina
#> 43                    Menasha, Wisconsin
#> 44                Marysville, Washington
#> 45             Santa Barbara, California
#> 46                      Fort Hood, Texas
#> 47                   Alturas, California
#> 48                      Washington, D.C.
#> 49                      Hialeah, Florida
#> 50              Santa Monica, California
#> 51               Federal Way, Washington
#> 52             Herkimer County, New York
#> 53                  Newtown, Connecticut
#> 54                Minneapolis, Minnesota
#> 55                  Oak Creek, Wisconsin
#> 56                      Aurora, Colorado
#> 57                   Seattle, Washington
#> 58                   Oakland, California
#> 59                     Norcross, Georgia
#> 60                Seal Beach, California
#> 61                   Carson City, Nevada
#> 62                       Tucson, Arizona
#> 63               Manchester, Connecticut
#> 64                  Parkland, Washington
#> 65                      Fort Hood, Texas
#> 66                  Binghamton, New York
#> 67              Carthage, North Carolina
#> 68                   Henderson, Kentucky
#> 69                      DeKalb, Illinois
#> 70                    Kirkwood, Missouri
#> 71                       Omaha, Nebraska
#> 72                    Crandon, Wisconsin
#> 73                  Blacksburg, Virginia
#> 74                  Salt Lake City, Utah
#> 75        Lancaster County, Pennsylvania
#> 76                   Seattle, Washington
#> 77                    Goleta, California
#> 78                   Red Lake, Minnesota
#> 79                 Brookfield, Wisconsin
#> 80                        Columbus, Ohio
#> 81                 Meridian, Mississippi
#> 82                Melrose Park, Illinois
#> 83              Wakefield, Massachusetts
#> 84                        Tampa, Florida
#> 85                      Honolulu, Hawaii
#> 86                     Fort Worth, Texas
#> 87                      Atlanta, Georgia
#> 88                   Littleton, Colorado
#> 89                   Springfield, Oregon
#> 90                   Jonesboro, Arkansas
#> 91                Newington, Connecticut
#> 92                    Orange, California
#> 93                 Aiken, South Carolina
#> 94              Fort Lauderdale, Florida
#> 95                 Corpus Christi, Texas
#> 96  Fairchild Air Force Base, Washington
#> 97                      Aurora, Colorado
#> 98                 Garden City, New York
#> 99          Fayetteville, North Carolina
#> 100            San Francisco, California
#> 101               Watkins Glen, New York
#> 102               Olivehurst, California
#> 103                  Royal Oak, Michigan
#> 104                      Iowa City, Iowa
#> 105                       Killeen, Texas
#> 106                Jacksonville, Florida
#> 107                 Louisville, Kentucky
#> 108                 Stockton, California
#> 109                Sunnyvale, California
#> 110                    Palm Bay, Florida
#> 111                     Edmond, Oklahoma
#> 112               San Ysidro, California
#> 113                        Dallas, Texas
#> 114                       Miami, Florida
#>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          summary
#> 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        PENDING
#> 2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        PENDING
#> 3                                                                                                                                                                                                                                                                                                                                                       Santino William LeGan, 19, fired indiscriminately into the crowd near a concert stage at the festival. He used an AK-47-style rifle, purchased legally in Nevada three weeks earlier. After apparently pausing to reload, he fired additional multiple rounds before police responding at the scene shot him to death. A witness described overhearing someone shout at LeGan, "Why are you doing this?" LeGan, who was dressed in camouflage, replied: “Because I'm really angry." The murdered victims included a 13-year-old girl, a man in his 20s, and six-year-old Stephen Romero.
#> 4                                                                                                                                                                                                                                                                                                                                                                                                   DeWayne Craddock, 40, a municipal city worker wielding handguns, a suppressor and high-capacity magazines, killed en masse inside a Virginia Beach muncipal building late in the day on a Friday, before dying in a prolonged gun battle with police. Craddock reportedly had submitted his resignation from his job that morning. He was a veteran of the Virginia Army National Guard, and "had a shaved head, bodybuilder’s physique and cameras in the windows of his house on a peaceful cul-de-sac," according to the Washington Post.
#> 5                                                                                                                                                                                                                                                                                                                                                                  Gary Martin, 45, went on a rampage inside the warehouse in response to being fired from his job and died soon thereafter in a shootout with police. Among his victims were five dead coworkers and five injured police officers. Martin had a felony record and lengthy history of domestic violence; he was able to obtain a gun despite having had his Illinois firearms ownership identification card revoked. According to a report from prosecutors, Martin told a co-worker the morning of the shooting that if he was fired he was going to kill employees and police.
#> 6                                                                                                                                                                                                                                                                                                                                                                                                                Jordan Witmer, 21, shot three people at a Ramada Hotel bar near Penn State University, including a former girlfriend he was there with. He then fled the bar, crashed his car about a mile away, and stormed into a random house, fatally shooting an elderly resident and then himself. Witmer, who had a legal carry permit for his handgun, had just finished a three-year stint in the US Army; ten days prior to the attack he had been convicted on drunk driving-related charges in Kentucky, where he'd been stationed.
#> 7   Zephen A. Xaver, 21, fatally shot five women inside a bank and then called the police to confess. He was armed with a handgun and wore a bulletproof vest. He reportedly ordered the women to lie down on the floor and shot them execution-style. After a standoff with police, he surrendered and was taken into custody. A week prior, Xaver had quit a job as a prison guard trainee, and authorities said they believed the shooting was "a random act" and that roberry did not appear to be a motive. An ex-girlfriend in Indiana told local media she'd been “scared for years” by Xaver’s talk of violence and death, but that her warnings to others (who she did not identify) were not taken seriously. She said she’d first met Xaver in a psychiatric hospital in 2013. In March 2017, Michigan State Police documented an incident in which Xaver indicated he was “possibly thinking of suicide by cop and taking hostages."
#> 8                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               Juan Lopez, 32, confronted his former fiancé, ER doctor Tamara O'Neal, before shooting her and opening fire on others at the hospital, including a responding police officer, Samuel Jimenez, and a pharmacy employee, Dayna Less. Lopez was fatally shot by a responding SWAT officer. Lopez had a history of domestic abuse against an ex-wife, and was kicked out of a fire department training academy for misconduct against female cadets.
#> 9                                                                                                                                                                                                                                                                                                                                                                                                Ian David Long, 28, dressed in black and armed with a handgun and a “smoke device,” approached the Borderline Bar & Grill — a country music venue popular with college students — close to midnight and opened fire, killing a security guard and then others in the club, including a sheriff’s deputy responding to the attack. Long was found dead at the scene from apparent suicide. He was a former Marine and had a history of interactions with local law enforcement, including a mental health evaluation in which he’d been cleared.
#> 10                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Robert D. Bowers, 46, shouted anti-Semitic slurs as he opened fire inside the Tree of Life synagogue during Saturday morning worship. He was armed with an assault rifle and multiple handguns and was apprehended after a standoff with police. His social media accounts contained virulent anti-Semitic content, and references to migrant caravan "invaders" hyped by President Trump and the Republican party ahead of the 2018 midterms elections.
#> 11                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Snochia Moseley, 26, reportedly a disgruntled employee, shot her victims outside the building and on the warehouse floor; she later died from a self-inflicted gunshot at a nearby hospital. (No law enforcement officers responding to her attack fired shots.)
#> 12                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Javier Casarez, 54, who was going through a bitter divorce, went on a shooting spree targeting his ex-wife and former coworkers at the trucking company. His attack included fatally shooting one victim who he pursued to a nearby sporting goods retailer, and two others at a private residence. After then carjacking a woman who was driving with a child (and letting the two go), Casarez fatally shot himself as law enforcement officials closed in on him.
#> 13                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Omar Enrique Santa Perez, 29, walked into the ground-floor lobby of a building in downtown Cincinnati shortly after 9 a.m. and opened fire. Within minutes, Perez was fatally wounded in a shootout with law enforcement officers responding to the scene.
#> 14                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Jarrod W. Ramos, 38, shot through the glass doors of the paper’s newsroom around 3pm to carry out his attack; police quickly responding to the scene found him hiding under a desk and apprehended him. Ramos had harbored a longstanding grudge against the paper over a 2011 column that had detailed his guilty plea for the harassment of a former female classmate. Ramos had sued the paper for defamation and lost.
#> 15                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Dimitrios Pagourtzis, a 17-year-old student, opened fire at Santa Fe High School with a shotgun and .38 revolver owned by his father; Pagourtzis killed 10 and injured at least 13 others before surrendering to authorities after a standoff and additional gunfire inside the school. (Pagourtzis reportedly had intended to commit suicide.) Investigators also found undetonated explosive devices in the vicinity. (FURTHER DETAILS PENDING.)
#> 16                                                                                                                                                                                                                               Travis Reinking, 29, opened fire around 3:30 a.m. in the parking lot of a Waffle House in Antioch, and continued shooting as he entered the restaurant. As he attempted to reload his AR-15, a bystander heroically wrestled the rifle away from Reinking, who then fled; he was captured by authorities the following day. Reinking had a history of erratic behavior and run-ins with law enforcement in his home state of Illinois, including claims that he was being stalked and harassed by pop star Taylor Swift. In July 2017, he was arrested at the White House after breaching security in an effort to speak with President Trump, reportedly claiming his right to do so as “a sovereign citizen.”
#> 17                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             Army veteran Albert Cheung Wong, 36, stormed a veterans home where he was previously under care, exchanging gunfire with a sheriff’s deputy and taking three women hostage, one of whom he’d previously threatened. After a standoff with law enforcement, he killed the three women and himself.
#> 18                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Nikolas J. Cruz, 19, heavily armed with an AR-15, tactical gear, and “countless magazines” of ammo, according to the Broward County Sheriff, attacked the high school as classes were ending for the day, killing at least 17 people and injuring many others. He was apprehended by authorities shortly after fleeing the campus.
#> 19                                                                                                                                                                                                                                                                                                                                                                                                                                                            Timothy O'Brien Smith, 28, wearing body armor and well-stocked with ammo, opened fire at a carwash early in the morning in this rural community, killing four people. A fifth victim, though not shot, suffered minor injuries. One of the deceased victims, 25-year-old Chelsie Cline, had been romantically involved with Smith and had broken off the relationship recently, according to her sister. Smith shot himself in the head and died later that night at the hospital.
#> 20                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Kevin Janson Neal, 44, went on an approximately 45-minute shooting spree in the rural community of Rancho Tehama Reserve in Northern California, including shooting up an elementary school, before being killed by law enforcement officers. Neal had also killed his wife at home.
#> 21                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             Devin Patrick Kelley, a 26-year-old ex-US Air Force airman, opened fire at the First Baptist Church in Sutherland Springs during Sunday morning services, killing at least 26 people and wounding and injuring 20 others. He left the church and fled in his vehicle after engaging in a gunfight with a local citizen; he soon crashed his vehicle and died from a self-inflicted gunshot wound.
#> 22                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Scott Allen Ostrem, 47, walked into a Walmart in a suburb north of Denver and fatally shot two men and a woman, then left the store and drove away. After an all-night manhunt, Ostrem, who had financial problems but no serious criminal history, was captured by police after being spotted near his apartment in Denver.
#> 23                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Radee Labeeb Prince, 37, fatally shot three people and wounded two others around 9am at Advance Granite Solutions, a home remodeling business where he worked near Baltimore. Hours later he shot and wounded a sixth person at a car dealership in Wilmington, Delaware. He was apprehended that evening following a manhunt by authorities.
#> 24                                                                                                                                                                                                                                                                                                                                                                                                                                                      Stephen Craig Paddock, 64, fired a barrage of rapid gunfire—using semiautomatic rifles modified with "bump stocks"—down on thousands of concertgoers on the Las Vegas Strip late on a Sunday night; Paddock had positioned himself in a corner suite on the 32nd floor of the Mandalay Bay Resort and Casino, where he took aim from broken out windows. Shortly after the attack began, police responding found Paddock inside the hotel suite, deceased from a self-inflicted gunshot.
#> 25                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             Jimmy Lam, 38, fatally shot three coworkers and wounded two others inside a UPS facility in San Francisco. Lam killed himself as law enforcement officers responded to the scene.
#> 26                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             Randy Stair, a 24-year-old worker at Weis grocery fatally shot three of his fellow employees. He reportedly fired 59 rounds with a pair of shotguns before turning the gun on himself as another co-worker fled the scene for help and law enforcement responded.
#> 27                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        John Robert Neumann, Jr., 45, a former employee of manufacturer Fiamma Inc. fatally shot five workers at the company, and then killed himself on the scene. He'd been fired from the company in April. The attack took place a week before the one-year anniversary of the Orlando nightclub massacre.
#> 28                                                                                                                                                                                                                                                                                                                                                                                                                                                                               Thomas Hartless, 43, shot and killed a former girlfriend and another employee of a nursing home, and fatally shot the Kirkersville police chief responding to the scene. Hartless' former girlfriend had recently obtained a court protection order against Hartless. Investigators later found more than 60 firearms in the home of Hartless, who was found dead at the scene of the attack, having turned his gun on himself, according to local authorities.
#> 29                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Kori Ali Muhammad, 39, opened fire along a street in downtown Fresno, killing three people randomly in an alleged hate crime prior to being apprehended by police. Muhammad, who is black, killed three white victims and later described his attack as being racially motivated; he also reportedly yelled 'Allahu Akbar' at the time he was arrested, but authorities indicated they found no links to Islamist terrorism.
#> 30                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         Esteban Santiago, 26, flew from Alaska to Fort Lauderdale, where he opened fire in the baggage claim area of the airport, killing five and wounding six before police aprehended him. (Numerous other people were reportedly injured while fleeing during the panic.)
#> 31                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Arcan Cetin, 20, killed a teen girl and three women in the cosmetics section of a Macy’s department store at the Cascade Mall. A man was critically wounded in the shooting and taken to Harborview Medical Center in Seattle, where he died. Cetin was apprehended by police a few hours after the shooting while driving a car near his residence.
#> 32                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         Gavin Long, 29, a former Marine who served in Iraq, killed three police offers responding to a 911 call, and wounded three others. He was killed in a shoot-out with other officers responding to the scene. Prior to the attack, Long posted prolifically on social media, where he expressed admiration for the cop killer in Dallas 10 days prior.
#> 33                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Micah Xavier Johnson, a 25-year-old Army veteran, targeted police at a peaceful Black Lives Matter protest, killing five officers and injuring nine others as well as two civilians. After a prolonged standoff in a downtown building, law enforcement killed Johnson using a robot-delivered bomb.
#> 34                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               Omar Mateen, 29, attacked the Pulse nighclub in Orlando in the early morning hours of June 12. He was killed by law enforcement who raided the club after a prolonged standoff.
#> 35                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Cedric L. Ford, who worked as a painter at a manufacturing company, shot victims from his car and at his workplace before being killed by police at the scene. Shortly before the rampage he had been served with a restraining order.
#> 36                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Jason B. Dalton, a driver for Uber, apparently selected his victims randomly as he went on a rampage over several hours in three different locations, including five people he shot in the parking lot of a Cracker Barrel restaurant. He was "arrested without incident" at a downtown Kalamazoo bar about six hours after the rampage began.
#> 37                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Syed Rizwan Farook left a Christmas party held at Inland Regional Center, later returning with Tashfeen Malik and the two opened fire, killing 14 and wounding 21, ten critically. The two were later killed by police as they fled in an SUV.
#> 38                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       Robert Lewis Dear, 57, shot and killed a police officer and two citizens when he opened fire at a Planned Parenthood health clinic in Colorado Springs, Colorado. Nine others were wounded. Dear was arrested after an hours-long standoff with police.
#> 39                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   Noah Harpham, 33, shot three people before dead in Colorado Springs before police killed him in a shootout.
#> 40                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  26-year-old Chris Harper Mercer opened fire at Umpqua Community College in southwest Oregon. The gunman shot himself to death after being wounded in a shootout with police.
#> 41                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Kuwaiti-born Mohammod Youssuf Abdulazeez, 24, a naturalized US citizen, opened fire at a Naval reserve center, and then drove to a military recruitment office where he shot and killed four Marines and a Navy service member, and wounded a police officer and another military service member. He was then fatally shot in an exchange of gunfire with law enforcement officers responding to the attack.
#> 42                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     Dylann Storm Roof, 21, shot and killed 9 people after opening fire at the Emanuel AME Church in Charleston, South Carolina. According to a roommate, he had allegedly been “planning something like that for six months."
#> 43                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           Sergio Valencia del Toro, 27, in what officials say was a random act, shot and killed three people including an 11-year-old girl before turning the gun on himself.
#> 44                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Jaylen Fryberg, 15, using a .40-caliber Berretta, shot five \nstudents at Marysville High School, including two of his cousins and three friends, killing all but one. Fryberg arranged to meet them for lunch in the school cafeteria by text. Fryberg was reportedly well-liked at the school and there was not believed to be any ill-will between him and his victims. He committed suicide at the scene.
#> 45                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     Elliot Rodger, 22, shot three people to death in the college town of Isla Vista near the University of California, Santa Barbara. He also shot others as he drove around town, and injured others by striking them with is vehicle. He committed suicide by shooting himself in his car as police closed in. Prior to the rampage, Rodger stabbed three people to death at his apartment.
#> 46                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   Army Specialist Ivan Lopez, 34, opened fire at the Fort Hood Army Post in Texas, killing three and wounding at least 12 others before shooting himself in the head after engaging with military police. Lt. Gen. Mark A. Milley told reporters that Lopez "had behavioral health and mental health" issues.
#> 47                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Cherie Lash Rhoades, 44, opened fire at the Cedarville Rancheria Tribal Office and Community Center, killing four and wounding two. After running out of ammunition, Rhoades grabbed a butcher knife and stabbed another person.
#> 48                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Aaron Alexis, 34, a military veteran and contractor from Texas, opened fire in the Navy installation, killing 12 people and wounding 8 before being shot dead by police.
#> 49                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Pedro Vargas, 42, set fire to his apartment, killed six people in the complex, and held another two hostages at gunpoint before a SWAT team stormed the building and fatally shot him.
#> 50                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   John Zawahri, 23, armed with a homemade assault rifle and high-capacity magazines, killed his brother and father at home and then headed to Santa Monica College, where he was eventually killed by police.
#> 51                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             Dennis Clark III, 27, shot and killed his girlfriend in their shared apartment, and then shot two witnesses in the building's parking lot and a third victim in another apartment, before being killed by police.
#> 52                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Kurt Myers, 64, shot six people in neighboring towns, killing two in a barbershop and two at a car care business, before being killed by officers in a shootout after a nearly 19-hour standoff.
#> 53                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Adam Lanza, 20, shot his mother dead at their home then drove to Sandy Hook Elementary school. He forced his way inside and opened fire, killing 20 children and six adults before committing suicide.
#> 54                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           Andrew Engeldinger, 36, upon learning he was being fired, went on a shooting rampage, killing the business owner, three fellow employees, and a UPS driver. He then killed himself.
#> 55                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     U.S. Army veteran Wade Michael Page, 40, opened fire in a Sikh gurdwara before he died from a self-inflicted gunshot would during a shootout with police.
#> 56                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           James Holmes, 24, opened fire in a movie theater during the opening night of "The Dark Night Rises" and was later arrested outside.
#> 57                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   Ian Stawicki, 40, gunned down four patrons at a cafe, and another person during a carjacking nearby, then shot himself as police closed in. (He died later that day in a Seattle hospital.)
#> 58                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     One L. Goh, 43, a former student, opened fire in a nursing classroom. He fled the scene by car and was arrested nearby a few hours later.
#> 59                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Jeong Soo Paek, 59, returned to a Korean spa from which he'd been kicked out after an altercation. He gunned down two of his sisters and their husbands before committing suicide.
#> 60                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Scott Evans Dekraai, 42, opened fire inside a hair salon and was later arrested. Victims killed in the attack included his ex-wife, who Dekraai had a history of violently abusing, according to court records. The two had also been involved in a bitter custody battle.
#> 61                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         Eduardo Sencion, 32, opened fire at an International House of Pancakes restaurant and later died from a self-inflicted gunshot wound.
#> 62                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Jared Loughner, 22, opened fire outside a Safeway during a constituent meeting with Congresswoman Gabrielle Giffords (D-Ariz.) before he was subdued by bystanders and arrested.
#> 63                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               Omar S. Thornton, 34, shot up his Hartford Beer Distributor workplace after facing disciplinary issues, then committed suicide.
#> 64                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       Maurice Clemmons, 37, a felon who was out on bail for child-rape charges, entered a coffee shop on a Sunday morning and shot four police officers who had gone there to use their laptops before their shifts. Clemmons, who was wounded fleeing the scene, was later shot dead by a police officer in Seattle after a two-day manhunt.
#> 65                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       Army psychiatrist Nidal Malik Hasan, 39, opened fire on an Army base in an attack linked to Islamist extremism. Hasan was injured during the attack and later arrested.
#> 66                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               Jiverly Wong, 41, opened fire at an American Civic Association center for immigrants before committing suicide.
#> 67                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Robert Stewart, 45, opened fire at a nursing home where his estranged wife worked before he was shot and arrested by a police officer.
#> 68                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Disgruntled employee Wesley Neal Higdon, 25, shot up an Atlantis Plastics factory after he was escorted out of his workplace for an argument with a supervisor. Higdon shot the supervisor outside the factory before opening fire on coworkers inside. He then committed suicide.
#> 69                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Steven Kazmierczak, 27, opened fire in a lecture hall, then shot and killed himself before police arrived.
#> 70                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Charles "Cookie" Lee Thornton, 52, went on a rampage at the city hall before being shot and killed by police.
#> 71                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           Robert A. Hawkins, 19, opened fire inside Westroads Mall before committing suicide.
#> 72                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         Off-duty sheriff's deputy Tyler Peterson, 20, opened fire inside an apartment after an argument at a homecoming party. He fled the scene and later committed suicide.
#> 73                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Virginia Tech student Seung-Hui Cho, 23, opened fire on his school's campus before committing suicide.
#> 74                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Sulejman Talović\u0087, 18, rampaged through the shopping center until he was shot dead by police.
#> 75                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Charles Carl Roberts, 32, shot 10 young girls in a one-room schoolhouse in Bart Township, killing 5, before taking his own life.
#> 76                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Kyle Aaron Huff, 28, opened fire at a rave afterparty in the Capitol Hill neighborhood of Seattle before committing suicide.
#> 77                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             Former postal worker Jennifer Sanmarco, 44, shot dead a former neighbor then drove to the mail processing plant where she used to work. Inside, she opened fire, killing six employees before committing suicide.
#> 78                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           Jeffrey Weise, 16, murdered his grandfather, who was a police officer, and grandfather's girlfriend. Weise then drove his grandfather's squad car to Red Lake Senior High School and opened fire on the reservation campus, killing another seven people before committing suicide.
#> 79                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Living Church of God member Terry Michael Ratzmann, 44, opened fire at a church meeting at a Sheraton hotel before committing suicide.
#> 80                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           Nathan Gale, 25, possibly upset about the breakup of Pantera, gunned down former Pantera guitarist Dimebag Darrell and three others at a Damageplan show before a police officer fatally shot Gale.
#> 81                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             Assembly line worker Douglas Williams, 48, opened fire at his Lockheed Martin workplace in a racially motivated attack before committing suicide.
#> 82                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Fired employee William D. Baker, 66, opened fire at his former Navistar workplace before committing suicide.
#> 83                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Michael McDermott, 42, opened fire on co-workers at Edgewater Technology and was later arrested.
#> 84                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       Hotel employee Silvio Leyva, 36, gunned down four coworkers at the Radisson Bay Harbor Inn before killing a woman outside who refused to give him her car. He was arrested shortly after the shootings.
#> 85                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Byran Koji Uyesugi, 40, a Xerox service technician, opened fire inside the building with a 9mm Glock. He fled and was later apprehended by police.
#> 86                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Larry Gene Ashbrook, 47, opened fire inside the Wedgwood Baptist Church during a prayer rally before committing suicide.
#> 87                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Day trader Mark O. Barton, 44, who had recently lost a substantial sum of money, went on a shooting spree through two day-trading firms. He started at the All-Tech Investment Group, where he worked, then went on to Momentum Securities. He fled and hours later, after being cornered by police outside a gas station, committed suicide. (Two days before the spree, he killed his wife and two children with a hammer.)
#> 88                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               Eric Harris, 18, and Dylan Klebold, 17, opened fire throughout Columbine High School before committing suicide.
#> 89                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            After he was expelled for having a gun in his locker, Kipland P. Kinkel, 15, a freshman at Thurston High, went on a shooting spree, killing his parents at home and two students at school. Five classmates wrestled Kipland to the ground before he was arrested.
#> 90                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               Mitchell Scott Johnson, 13, and Andrew Douglas Golden, 11, two juveniles, ambushed students and teachers as they left the school; they were apprehended by police at the scene.
#> 91                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     Lottery worker Matthew Beck, 35, gunned down four bosses over a salary dispute before committing suicide.
#> 92                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Former Caltrans employee Arturo Reyes Torres, 41, opened fire at a maintenance yard after he was fired for allegedly selling government materials he'd stolen from work. He was shot dead by police.
#> 93                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         Ex-con Hastings Arthur Wise, 43, opened fire at the R.E. Phelon Company in retaliation for being fired after an argument with a supervisor. He attempted suicide by ingesting insecticide, failed, and was executed by the state of South Carolina eight years later.
#> 94                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Fired city park employee Clifton McCree, 41, opened fire on former coworkers he called "racist devils" inside their municipal trailer in an act of revenge after failing a drug test. He then committed suicide.
#> 95                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           Disgruntled former metallurgist James Daniel Simpson, 28, opened fire throughout the Walter Rossler Company where he had worked before exiting the building and committing suicide.
#> 96                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Former airman Dean Allen Mellberg, 20, opened fire inside a hospital at the Fairchild Air Force Base before he was shot dead by a military police officer outside.
#> 97                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Nathan Dunlap, 19, a recently fired Chuck E. Cheese's employee, went on a rampage through his former workplace and was arrested the following day. He now awaits execution on death row.
#> 98                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Colin Ferguson, 35, opened fire on an eastbound Long Island Rail Road train as it approached a Garden City station. He was later arrested.
#> 99                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Army Sgt. Kenneth Junior French, 22, opened fire inside Luigi's Italian restaurant while ranting about gays in the military before he was shot and arrested by police.
#> 100                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Failed businessman Gian Luigi Ferri, 55, opened fire throughout an office building before he committed suicide inside as police pursued him.
#> 101                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  John T. Miller, 50, killed four child-support workers in a county office building before turning the gun on himself.  Miller was upset about a court order garnishing his paycheck to cover overdue child-support payments.
#> 102                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Former Lindhurst High School student Eric Houston, 20, angry about various personal failings, killed three students and a teacher at the school before surrendering to police after an eight-hour standoff. He was later sentenced to death.
#> 103                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   Laid-off postal worker Thomas McIlvane, 31, opened fire at his former workplace before committing suicide.
#> 104                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Former graduate student Gang Lu, 28, went on a rampage on campus and then committed suicide at the scene.
#> 105                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                George Hennard, 35, drove his pickup truck into a Luby's cafeteria and opened fire before committing suicide.
#> 106                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        James Edward Pough, 42, opened fire at a General Motors Acceptance Corporation office before committing suicide. (The day prior, Pough killed a pimp and prostitute and injured two others. Those victims are not included in the mass murder count.)
#> 107                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         Joseph T. Wesbecker, 47, gunned down eight people at his former workplace before committing suicide.
#> 108                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           Patrick Purdy, 26, an alcoholic with a police record, launched an assault at Cleveland Elementary School, where many young Southeast Asian immigrants were enrolled. Purdy killed himself with a shot to the head.
#> 109                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Former ESL Incorporated employee Richard Farley, 39, gunned down seven people at his former workplace, after stalking and harassing a coworker he was romantically interested in. He was later arrested and now sits on death row at San Quentin.
#> 110                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Retired librarian William Cruse, 59, was paranoid neighbors gossiped that he was gay. He drove to a Publix supermarket, killing two Florida Tech students en route before opening fire outside and killing a woman. He then drove to a Winn-Dixie supermarket and killed three more, including two police officers. Cruse was arrested after taking a hostage and died on death row in 2009.
#> 111                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Postal worker Patrick Sherrill, 44, opened fire at a post office before committing suicide.
#> 112                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                James Oliver Huberty, 41, opened fire in a McDonald's restaurant before he was shot dead by a police officer.
#> 113                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     Abdelkrim Belachheb, 39, opened fire at an upscale nightclub after a woman rejected his advances. He was later arrested.
#> 114                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               Junior high school teacher Carl Robert Brown, 51, opened fire inside a welding shop and was later shot dead by a witness as he fled the scene.
#>     fatalities injured total_victims location_type  male age_of_shooter
#> 1            9      27            36         Other  TRUE             24
#> 2           20      26            46     Workplace  TRUE             21
#> 3            3      12            15         Other  TRUE             19
#> 4           12       4            16     Workplace  TRUE             40
#> 5            5       6            11     Workplace  TRUE             45
#> 6            3       1             4         Other  TRUE             21
#> 7            5       0             5     Workplace  TRUE             21
#> 8            3       0             3     Workplace  TRUE             32
#> 9           12      22            34         Other  TRUE             28
#> 10          11       6            17     Religious  TRUE             46
#> 11           3       3             6     Workplace FALSE             26
#> 12           5       0             5     Workplace  TRUE             54
#> 13           3       2             5     Workplace  TRUE             29
#> 14           5       2             7     Workplace  TRUE             38
#> 15          10      13            23        School  TRUE             17
#> 16           4       4             8         Other  TRUE             29
#> 17           3       0             3     Workplace  TRUE             36
#> 18          17      17            34        School  TRUE             19
#> 19           4       1             5         Other  TRUE             28
#> 20           5      10            15         Other  TRUE             44
#> 21          26      20            46     Religious  TRUE             26
#> 22           3       0             3         Other  TRUE             47
#> 23           3       3             6     Workplace  TRUE             37
#> 24          58     546           604         Other  TRUE             64
#> 25           3       2             5     Workplace  TRUE             38
#> 26           3       0             3     Workplace  TRUE             24
#> 27           5       0             5     Workplace  TRUE             45
#> 28           3       0             3     Workplace  TRUE             43
#> 29           3       0             3         Other  TRUE             39
#> 30           5       6            11       Airport  TRUE             26
#> 31           5       0             5         Other  TRUE             20
#> 32           3       3             6         Other  TRUE             29
#> 33           5      11            16         Other  TRUE             25
#> 34          49      53           102         Other  TRUE             29
#> 35           3      14            17     Workplace  TRUE             38
#> 36           6       2             8         Other  TRUE             45
#> 37          14      21            35     Workplace  TRUE             28
#> 38           3       9            12     Workplace  TRUE             57
#> 39           3       0             3         Other  TRUE             33
#> 40           9       9            18        School  TRUE             26
#> 41           5       2             7      Military  TRUE             24
#> 42           9       1            10     Religious  TRUE             21
#> 43           3       1             4         Other  TRUE             27
#> 44           5       1             6        School  TRUE             15
#> 45           6      13            19        School  TRUE             22
#> 46           3      12            15      Military  TRUE             34
#> 47           4       2             6         Other FALSE             44
#> 48          12       8            20      Military  TRUE             34
#> 49           7       0             7         Other  TRUE             42
#> 50           6       3             9         Other  TRUE             23
#> 51           5       0             5         Other  TRUE             27
#> 52           5       2             7         Other  TRUE             64
#> 53          27       2            29        School  TRUE             20
#> 54           7       1             8     Workplace  TRUE             36
#> 55           7       3            10     Religious  TRUE             40
#> 56          12      70            82         Other  TRUE             24
#> 57           6       1             7         Other  TRUE             40
#> 58           7       3            10        School  TRUE             43
#> 59           5       0             5         Other  TRUE             59
#> 60           8       1             9         Other  TRUE             42
#> 61           5       7            12         Other  TRUE             32
#> 62           6      13            19         Other  TRUE             22
#> 63           9       2            11     Workplace  TRUE             34
#> 64           4       1             5         Other  TRUE             37
#> 65          13      30            43      Military  TRUE             39
#> 66          14       4            18         Other  TRUE             41
#> 67           8       3            11         Other  TRUE             45
#> 68           6       1             7     Workplace  TRUE             25
#> 69           5      21            26        School  TRUE             27
#> 70           6       2             8         Other  TRUE             52
#> 71           9       4            13         Other  TRUE             19
#> 72           6       1             7         Other  TRUE             20
#> 73          32      23            55        School  TRUE             23
#> 74           6       4            10         Other  TRUE             18
#> 75           6       5            11        School  TRUE             32
#> 76           7       2             9         Other  TRUE             28
#> 77           8       0             8     Workplace FALSE             44
#> 78          10       5            15        School  TRUE             16
#> 79           7       4            11     Religious  TRUE             44
#> 80           5       7            12         Other  TRUE             25
#> 81           7       8            15     Workplace  TRUE             48
#> 82           5       4             9     Workplace  TRUE             66
#> 83           7       0             7     Workplace  TRUE             42
#> 84           5       3             8     Workplace  TRUE             36
#> 85           7       0             7     Workplace  TRUE             40
#> 86           8       7            15     Religious  TRUE             47
#> 87           9      13            22     Workplace  TRUE             44
#> 88          13      24            37        School  TRUE             17
#> 89           4      25            29        School  TRUE             15
#> 90           5      10            15        School  TRUE             11
#> 91           5       1             6     Workplace  TRUE             35
#> 92           5       2             7     Workplace  TRUE             41
#> 93           4       3             7     Workplace  TRUE             43
#> 94           6       1             7     Workplace  TRUE             41
#> 95           6       0             6     Workplace  TRUE             28
#> 96           5      23            28      Military  TRUE             20
#> 97           4       1             5     Workplace  TRUE             19
#> 98           6      19            25         Other  TRUE             35
#> 99           4       8            12         Other  TRUE             22
#> 100          9       6            15         Other  TRUE             55
#> 101          5       0             5         Other  TRUE             50
#> 102          4      10            14        School  TRUE             20
#> 103          5       5            10     Workplace  TRUE             31
#> 104          6       1             7        School  TRUE             28
#> 105         24      20            44         Other  TRUE             35
#> 106         10       4            14         Other  TRUE             42
#> 107          9      12            21     Workplace  TRUE             47
#> 108          6      29            35        School  TRUE             26
#> 109          7       4            11     Workplace  TRUE             39
#> 110          6      14            20         Other  TRUE             59
#> 111         15       6            21     Workplace  TRUE             44
#> 112         22      19            41         Other  TRUE             41
#> 113          6       1             7         Other  TRUE             39
#> 114          8       3            11         Other  TRUE             51
#>                race prior_mental_illness
#> 1              <NA>                 <NA>
#> 2             White                 <NA>
#> 3              <NA>                 <NA>
#> 4             Black                 <NA>
#> 5             Black                  Yes
#> 6             White                 <NA>
#> 7             White                  Yes
#> 8            Latino                 <NA>
#> 9              <NA>                  Yes
#> 10            White                 <NA>
#> 11            Black                 <NA>
#> 12           Latino                 <NA>
#> 13           Latino                  Yes
#> 14            White                 <NA>
#> 15            White                 <NA>
#> 16            White                  Yes
#> 17            Asian                  Yes
#> 18            White                  Yes
#> 19            White                 <NA>
#> 20            White                 <NA>
#> 21            White                  Yes
#> 22            White                 <NA>
#> 23            Black                 <NA>
#> 24            White                 <NA>
#> 25            Asian                  Yes
#> 26            White                 <NA>
#> 27             <NA>                 <NA>
#> 28            White                  Yes
#> 29            Black                 <NA>
#> 30           Latino                  Yes
#> 31             <NA>                  Yes
#> 32            Black                  Yes
#> 33            Black                 <NA>
#> 34            Other                 <NA>
#> 35            Black                 <NA>
#> 36            White                 <NA>
#> 37            Other                 <NA>
#> 38            White                 <NA>
#> 39            White                 <NA>
#> 40            Other                 <NA>
#> 41            Other                 <NA>
#> 42            White                 <NA>
#> 43           Latino                  Yes
#> 44  Native American                 <NA>
#> 45            White                  Yes
#> 46           Latino                 <NA>
#> 47  Native American                 <NA>
#> 48            Black                  Yes
#> 49           Latino                 <NA>
#> 50            White                  Yes
#> 51            Black                   No
#> 52            White                   No
#> 53            White                  Yes
#> 54            White                  Yes
#> 55            White                  Yes
#> 56            White                  Yes
#> 57            White                  Yes
#> 58            Asian                  Yes
#> 59            Asian                  Yes
#> 60            White                  Yes
#> 61           Latino                  Yes
#> 62            White                  Yes
#> 63            Black                   No
#> 64            Black                  Yes
#> 65            Other                 <NA>
#> 66            Asian                  Yes
#> 67            White                  Yes
#> 68            White                   No
#> 69            White                  Yes
#> 70            Black                   No
#> 71            White                  Yes
#> 72            White                 <NA>
#> 73            Asian                  Yes
#> 74            White                 <NA>
#> 75            White                   No
#> 76            White                   No
#> 77            White                  Yes
#> 78  Native American                  Yes
#> 79            White                  Yes
#> 80            White                  Yes
#> 81            White                  Yes
#> 82            Black                   No
#> 83            White                  Yes
#> 84           Latino                  Yes
#> 85            Asian                  Yes
#> 86            White                  Yes
#> 87            White                  Yes
#> 88            White                  Yes
#> 89            White                  Yes
#> 90            White                   No
#> 91            White                  Yes
#> 92           Latino                   No
#> 93            Black                   No
#> 94            Black                  Yes
#> 95             <NA>                   No
#> 96            White                  Yes
#> 97            Black                 <NA>
#> 98            Black                  Yes
#> 99            White                   No
#> 100           White                   No
#> 101           White                  Yes
#> 102           White                   No
#> 103           White                  Yes
#> 104           Asian                 <NA>
#> 105           White                   No
#> 106           Black                   No
#> 107           White                  Yes
#> 108           White                  Yes
#> 109           White                  Yes
#> 110           White                  Yes
#> 111           White                 <NA>
#> 112           White                  Yes
#> 113           White                  Yes
#> 114           White                  Yes

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )
#> Error in mass_shootings %>% drop_na(race) %>% ggplot(mapping = aes(x = fct_infreq(race))): could not find function "%>%"

Created on 2021-02-18 by the reprex package (v0.3.0)

reillyoflaherty commented 3 years ago
library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case   year month   day location summary fatalities injured total_victims
#>    <chr> <dbl> <chr> <int> <chr>    <chr>        <dbl>   <dbl>         <dbl>
#>  1 Dayt…  2019 Aug       4 Dayton,… "PENDI…          9      27            36
#>  2 El P…  2019 Aug       3 El Paso… "PENDI…         20      26            46
#>  3 Gilr…  2019 Jul      28 Gilroy,… "Santi…          3      12            15
#>  4 Virg…  2019 May      31 Virgini… "DeWay…         12       4            16
#>  5 Harr…  2019 Feb      15 Aurora,… "Gary …          5       6            11
#>  6 Penn…  2019 Jan      24 State C… "Jorda…          3       1             4
#>  7 SunT…  2019 Jan      23 Sebring… "Zephe…          5       0             5
#>  8 Merc…  2018 Nov      19 Chicago… "Juan …          3       0             3
#>  9 Thou…  2018 Nov       7 Thousan… "Ian D…         12      22            34
#> 10 Tree…  2018 Oct      27 Pittsbu… "Rober…         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-02-18 by the reprex package (v0.3.0)

bethwang06 commented 3 years ago
library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case     year month   day location summary   fatalities injured total_victims
#>    <chr>   <dbl> <chr> <int> <chr>    <chr>          <dbl>   <dbl>         <dbl>
#>  1 Dayton…  2019 Aug       4 Dayton,… "PENDING"          9      27            36
#>  2 El Pas…  2019 Aug       3 El Paso… "PENDING"         20      26            46
#>  3 Gilroy…  2019 Jul      28 Gilroy,… "Santino…          3      12            15
#>  4 Virgin…  2019 May      31 Virgini… "DeWayne…         12       4            16
#>  5 Harry …  2019 Feb      15 Aurora,… "Gary Ma…          5       6            11
#>  6 Pennsy…  2019 Jan      24 State C… "Jordan …          3       1             4
#>  7 SunTru…  2019 Jan      23 Sebring… "Zephen …          5       0             5
#>  8 Mercy …  2018 Nov      19 Chicago… "Juan Lo…          3       0             3
#>  9 Thousa…  2018 Nov       7 Thousan… "Ian Dav…         12      22            34
#> 10 Tree o…  2018 Oct      27 Pittsbu… "Robert …         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-07-13 by the reprex package (v2.0.0)

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.1.0 (2021-05-18) #> os macOS Big Sur 10.16 #> system x86_64, darwin17.0 #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz America/Chicago #> date 2021-07-13 #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.1.0) #> backports 1.2.1 2020-12-09 [1] CRAN (R 4.1.0) #> broom 0.7.7 2021-06-13 [1] CRAN (R 4.1.0) #> cellranger 1.1.0 2016-07-27 [1] CRAN (R 4.1.0) #> cli 2.5.0 2021-04-26 [1] CRAN (R 4.1.0) #> colorspace 2.0-1 2021-05-04 [1] CRAN (R 4.1.0) #> crayon 1.4.1 2021-02-08 [1] CRAN (R 4.1.0) #> curl 4.3.1 2021-04-30 [1] CRAN (R 4.1.0) #> DBI 1.1.1 2021-01-15 [1] CRAN (R 4.1.0) #> dbplyr 2.1.1 2021-04-06 [1] CRAN (R 4.1.0) #> digest 0.6.27 2020-10-24 [1] CRAN (R 4.1.0) #> dplyr * 1.0.7 2021-06-18 [1] CRAN (R 4.1.0) #> ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.1.0) #> evaluate 0.14 2019-05-28 [1] CRAN (R 4.1.0) #> fansi 0.5.0 2021-05-25 [1] CRAN (R 4.1.0) #> farver 2.1.0 2021-02-28 [1] CRAN (R 4.1.0) #> forcats * 0.5.1 2021-01-27 [1] CRAN (R 4.1.0) #> fs 1.5.0 2020-07-31 [1] CRAN (R 4.1.0) #> generics 0.1.0 2020-10-31 [1] CRAN (R 4.1.0) #> ggplot2 * 3.3.4 2021-06-16 [1] CRAN (R 4.1.0) #> glue 1.4.2 2020-08-27 [1] CRAN (R 4.1.0) #> gtable 0.3.0 2019-03-25 [1] CRAN (R 4.1.0) #> haven 2.4.1 2021-04-23 [1] CRAN (R 4.1.0) #> highr 0.9 2021-04-16 [1] CRAN (R 4.1.0) #> hms 1.1.0 2021-05-17 [1] CRAN (R 4.1.0) #> htmltools 0.5.1.1 2021-01-22 [1] CRAN (R 4.1.0) #> httr 1.4.2 2020-07-20 [1] CRAN (R 4.1.0) #> jsonlite 1.7.2 2020-12-09 [1] CRAN (R 4.1.0) #> knitr 1.33 2021-04-24 [1] CRAN (R 4.1.0) #> labeling 0.4.2 2020-10-20 [1] CRAN (R 4.1.0) #> lifecycle 1.0.0 2021-02-15 [1] CRAN (R 4.1.0) #> lubridate 1.7.10 2021-02-26 [1] CRAN (R 4.1.0) #> magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.1.0) #> mime 0.10 2021-02-13 [1] CRAN (R 4.1.0) #> modelr 0.1.8 2020-05-19 [1] CRAN (R 4.1.0) #> munsell 0.5.0 2018-06-12 [1] CRAN (R 4.1.0) #> pillar 1.6.1 2021-05-16 [1] CRAN (R 4.1.0) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.1.0) #> purrr * 0.3.4 2020-04-17 [1] CRAN (R 4.1.0) #> R6 2.5.0 2020-10-28 [1] CRAN (R 4.1.0) #> rcfss * 0.2.1 2021-06-23 [1] Github (uc-cfss/rcfss@5b60f61) #> Rcpp 1.0.6 2021-01-15 [1] CRAN (R 4.1.0) #> readr * 1.4.0 2020-10-05 [1] CRAN (R 4.1.0) #> readxl 1.3.1 2019-03-13 [1] CRAN (R 4.1.0) #> reprex 2.0.0 2021-04-02 [1] CRAN (R 4.1.0) #> rlang 0.4.11 2021-04-30 [1] CRAN (R 4.1.0) #> rmarkdown 2.9 2021-06-15 [1] CRAN (R 4.1.0) #> rstudioapi 0.13 2020-11-12 [1] CRAN (R 4.1.0) #> rvest 1.0.0 2021-03-09 [1] CRAN (R 4.1.0) #> scales 1.1.1 2020-05-11 [1] CRAN (R 4.1.0) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.1.0) #> stringi 1.6.2 2021-05-17 [1] CRAN (R 4.1.0) #> stringr * 1.4.0 2019-02-10 [1] CRAN (R 4.1.0) #> styler 1.4.1 2021-03-30 [1] CRAN (R 4.1.0) #> tibble * 3.1.2 2021-05-16 [1] CRAN (R 4.1.0) #> tidyr * 1.1.3 2021-03-03 [1] CRAN (R 4.1.0) #> tidyselect 1.1.1 2021-04-30 [1] CRAN (R 4.1.0) #> tidyverse * 1.3.1 2021-04-15 [1] CRAN (R 4.1.0) #> utf8 1.2.1 2021-03-12 [1] CRAN (R 4.1.0) #> vctrs 0.3.8 2021-04-29 [1] CRAN (R 4.1.0) #> withr 2.4.2 2021-04-18 [1] CRAN (R 4.1.0) #> xfun 0.24 2021-06-15 [1] CRAN (R 4.1.0) #> xml2 1.3.2 2020-04-23 [1] CRAN (R 4.1.0) #> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.1.0) #> #> [1] /Library/Frameworks/R.framework/Versions/4.1/Resources/library ```
ssmyzs commented 3 years ago
## Copy the code below to generate a reproducible example
## using the reprex package. Once you generate it, post it on
## https://github.com/uc-cfss/Discussion/issues/181

library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case     year month   day location summary   fatalities injured total_victims
#>    <chr>   <dbl> <chr> <int> <chr>    <chr>          <dbl>   <dbl>         <dbl>
#>  1 Dayton…  2019 Aug       4 Dayton,… "PENDING"          9      27            36
#>  2 El Pas…  2019 Aug       3 El Paso… "PENDING"         20      26            46
#>  3 Gilroy…  2019 Jul      28 Gilroy,… "Santino…          3      12            15
#>  4 Virgin…  2019 May      31 Virgini… "DeWayne…         12       4            16
#>  5 Harry …  2019 Feb      15 Aurora,… "Gary Ma…          5       6            11
#>  6 Pennsy…  2019 Jan      24 State C… "Jordan …          3       1             4
#>  7 SunTru…  2019 Jan      23 Sebring… "Zephen …          5       0             5
#>  8 Mercy …  2018 Nov      19 Chicago… "Juan Lo…          3       0             3
#>  9 Thousa…  2018 Nov       7 Thousan… "Ian Dav…         12      22            34
#> 10 Tree o…  2018 Oct      27 Pittsbu… "Robert …         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )
cslewis12 commented 3 years ago
## Copy the code below to generate a reproducible example
## using the reprex package. Once you generate it, post it on
## https://github.com/uc-cfss/Discussion/issues/181

library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case     year month   day location summary   fatalities injured total_victims
#>    <chr>   <dbl> <chr> <int> <chr>    <chr>          <dbl>   <dbl>         <dbl>
#>  1 Dayton…  2019 Aug       4 Dayton,… "PENDING"          9      27            36
#>  2 El Pas…  2019 Aug       3 El Paso… "PENDING"         20      26            46
#>  3 Gilroy…  2019 Jul      28 Gilroy,… "Santino…          3      12            15
#>  4 Virgin…  2019 May      31 Virgini… "DeWayne…         12       4            16
#>  5 Harry …  2019 Feb      15 Aurora,… "Gary Ma…          5       6            11
#>  6 Pennsy…  2019 Jan      24 State C… "Jordan …          3       1             4
#>  7 SunTru…  2019 Jan      23 Sebring… "Zephen …          5       0             5
#>  8 Mercy …  2018 Nov      19 Chicago… "Juan Lo…          3       0             3
#>  9 Thousa…  2018 Nov       7 Thousan… "Ian Dav…         12      22            34
#> 10 Tree o…  2018 Oct      27 Pittsbu… "Robert …         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-07-13 by the reprex package (v2.0.0)

dipro-ray commented 3 years ago
## Copy the code below to generate a reproducible example
## using the reprex package. Once you generate it, post it on
## https://github.com/uc-cfss/Discussion/issues/181

library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case     year month   day location summary   fatalities injured total_victims
#>    <chr>   <dbl> <chr> <int> <chr>    <chr>          <dbl>   <dbl>         <dbl>
#>  1 Dayton…  2019 Aug       4 Dayton,… "PENDING"          9      27            36
#>  2 El Pas…  2019 Aug       3 El Paso… "PENDING"         20      26            46
#>  3 Gilroy…  2019 Jul      28 Gilroy,… "Santino…          3      12            15
#>  4 Virgin…  2019 May      31 Virgini… "DeWayne…         12       4            16
#>  5 Harry …  2019 Feb      15 Aurora,… "Gary Ma…          5       6            11
#>  6 Pennsy…  2019 Jan      24 State C… "Jordan …          3       1             4
#>  7 SunTru…  2019 Jan      23 Sebring… "Zephen …          5       0             5
#>  8 Mercy …  2018 Nov      19 Chicago… "Juan Lo…          3       0             3
#>  9 Thousa…  2018 Nov       7 Thousan… "Ian Dav…         12      22            34
#> 10 Tree o…  2018 Oct      27 Pittsbu… "Robert …         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-07-13 by the reprex package (v2.0.0)

agodinez711 commented 3 years ago
library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case     year month   day location summary   fatalities injured total_victims
#>    <chr>   <dbl> <chr> <int> <chr>    <chr>          <dbl>   <dbl>         <dbl>
#>  1 Dayton…  2019 Aug       4 Dayton,… "PENDING"          9      27            36
#>  2 El Pas…  2019 Aug       3 El Paso… "PENDING"         20      26            46
#>  3 Gilroy…  2019 Jul      28 Gilroy,… "Santino…          3      12            15
#>  4 Virgin…  2019 May      31 Virgini… "DeWayne…         12       4            16
#>  5 Harry …  2019 Feb      15 Aurora,… "Gary Ma…          5       6            11
#>  6 Pennsy…  2019 Jan      24 State C… "Jordan …          3       1             4
#>  7 SunTru…  2019 Jan      23 Sebring… "Zephen …          5       0             5
#>  8 Mercy …  2018 Nov      19 Chicago… "Juan Lo…          3       0             3
#>  9 Thousa…  2018 Nov       7 Thousan… "Ian Dav…         12      22            34
#> 10 Tree o…  2018 Oct      27 Pittsbu… "Robert …         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-07-13 by the reprex package (v2.0.0)

Maggie-Rivera commented 3 years ago
## Copy the code below to generate a reproducible example
## using the reprex package. Once you generate it, post it on
## https://github.com/uc-cfss/Discussion/issues/181

library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case     year month   day location summary   fatalities injured total_victims
#>    <chr>   <dbl> <chr> <int> <chr>    <chr>          <dbl>   <dbl>         <dbl>
#>  1 Dayton…  2019 Aug       4 Dayton,… "PENDING"          9      27            36
#>  2 El Pas…  2019 Aug       3 El Paso… "PENDING"         20      26            46
#>  3 Gilroy…  2019 Jul      28 Gilroy,… "Santino…          3      12            15
#>  4 Virgin…  2019 May      31 Virgini… "DeWayne…         12       4            16
#>  5 Harry …  2019 Feb      15 Aurora,… "Gary Ma…          5       6            11
#>  6 Pennsy…  2019 Jan      24 State C… "Jordan …          3       1             4
#>  7 SunTru…  2019 Jan      23 Sebring… "Zephen …          5       0             5
#>  8 Mercy …  2018 Nov      19 Chicago… "Juan Lo…          3       0             3
#>  9 Thousa…  2018 Nov       7 Thousan… "Ian Dav…         12      22            34
#> 10 Tree o…  2018 Oct      27 Pittsbu… "Robert …         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-07-13 by the reprex package (v2.0.0)

karenliu0212 commented 3 years ago
## Copy the code below to generate a reproducible example
## using the reprex package. Once you generate it, post it on
## https://github.com/uc-cfss/Discussion/issues/181

library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case     year month   day location summary   fatalities injured total_victims
#>    <chr>   <dbl> <chr> <int> <chr>    <chr>          <dbl>   <dbl>         <dbl>
#>  1 Dayton…  2019 Aug       4 Dayton,… "PENDING"          9      27            36
#>  2 El Pas…  2019 Aug       3 El Paso… "PENDING"         20      26            46
#>  3 Gilroy…  2019 Jul      28 Gilroy,… "Santino…          3      12            15
#>  4 Virgin…  2019 May      31 Virgini… "DeWayne…         12       4            16
#>  5 Harry …  2019 Feb      15 Aurora,… "Gary Ma…          5       6            11
#>  6 Pennsy…  2019 Jan      24 State C… "Jordan …          3       1             4
#>  7 SunTru…  2019 Jan      23 Sebring… "Zephen …          5       0             5
#>  8 Mercy …  2018 Nov      19 Chicago… "Juan Lo…          3       0             3
#>  9 Thousa…  2018 Nov       7 Thousan… "Ian Dav…         12      22            34
#> 10 Tree o…  2018 Oct      27 Pittsbu… "Robert …         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-07-13 by the reprex package (v2.0.0)

Tony-Zong commented 3 years ago
## Copy the code below to generate a reproducible example
## using the reprex package. Once you generate it, post it on
## https://github.com/uc-cfss/Discussion/issues/181

library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case     year month   day location summary   fatalities injured total_victims
#>    <chr>   <dbl> <chr> <int> <chr>    <chr>          <dbl>   <dbl>         <dbl>
#>  1 Dayton…  2019 Aug       4 Dayton,… "PENDING"          9      27            36
#>  2 El Pas…  2019 Aug       3 El Paso… "PENDING"         20      26            46
#>  3 Gilroy…  2019 Jul      28 Gilroy,… "Santino…          3      12            15
#>  4 Virgin…  2019 May      31 Virgini… "DeWayne…         12       4            16
#>  5 Harry …  2019 Feb      15 Aurora,… "Gary Ma…          5       6            11
#>  6 Pennsy…  2019 Jan      24 State C… "Jordan …          3       1             4
#>  7 SunTru…  2019 Jan      23 Sebring… "Zephen …          5       0             5
#>  8 Mercy …  2018 Nov      19 Chicago… "Juan Lo…          3       0             3
#>  9 Thousa…  2018 Nov       7 Thousan… "Ian Dav…         12      22            34
#> 10 Tree o…  2018 Oct      27 Pittsbu… "Robert …         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-07-13 by the reprex package (v2.0.0)

gdicera commented 3 years ago
## Copy the code below to generate a reproducible example
## using the reprex package. Once you generate it, post it on
## https://github.com/uc-cfss/Discussion/issues/181

library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case     year month   day location summary   fatalities injured total_victims
#>    <chr>   <dbl> <chr> <int> <chr>    <chr>          <dbl>   <dbl>         <dbl>
#>  1 Dayton…  2019 Aug       4 Dayton,… "PENDING"          9      27            36
#>  2 El Pas…  2019 Aug       3 El Paso… "PENDING"         20      26            46
#>  3 Gilroy…  2019 Jul      28 Gilroy,… "Santino…          3      12            15
#>  4 Virgin…  2019 May      31 Virgini… "DeWayne…         12       4            16
#>  5 Harry …  2019 Feb      15 Aurora,… "Gary Ma…          5       6            11
#>  6 Pennsy…  2019 Jan      24 State C… "Jordan …          3       1             4
#>  7 SunTru…  2019 Jan      23 Sebring… "Zephen …          5       0             5
#>  8 Mercy …  2018 Nov      19 Chicago… "Juan Lo…          3       0             3
#>  9 Thousa…  2018 Nov       7 Thousan… "Ian Dav…         12      22            34
#> 10 Tree o…  2018 Oct      27 Pittsbu… "Robert …         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-07-13 by the reprex package (v2.0.0)

annikaludwig commented 3 years ago

library(tidyverse)

get data from rcfss package

install latest version if not already installed

devtools::install_github("uc-cfss/rcfss")

library(rcfss)

load the data

data("mass_shootings") mass_shootings

> # A tibble: 114 x 14

> case year month day location summary fatalities injured total_victims

>

> 1 Dayton… 2019 Aug 4 Dayton,… "PENDING" 9 27 36

> 2 El Pas… 2019 Aug 3 El Paso… "PENDING" 20 26 46

> 3 Gilroy… 2019 Jul 28 Gilroy,… "Santino… 3 12 15

> 4 Virgin… 2019 May 31 Virgini… "DeWayne… 12 4 16

> 5 Harry … 2019 Feb 15 Aurora,… "Gary Ma… 5 6 11

> 6 Pennsy… 2019 Jan 24 State C… "Jordan … 3 1 4

> 7 SunTru… 2019 Jan 23 Sebring… "Zephen … 5 0 5

> 8 Mercy … 2018 Nov 19 Chicago… "Juan Lo… 3 0 3

> 9 Thousa… 2018 Nov 7 Thousan… "Ian Dav… 12 22 34

> 10 Tree o… 2018 Oct 27 Pittsbu… "Robert … 11 6 17

> # … with 104 more rows, and 5 more variables: location_type , male ,

> # age_of_shooter , race , prior_mental_illness

Generate a bar chart that identifies the number of mass shooters

associated with each race category. The bars should be sorted

from highest to lowest.

using forcats::fct_infreq() and using the raw data for plotting

mass_shootings %>% drop_na(race) %>% ggplot(mapping = aes(x = fct_infreq(race))) + geom_bar() + coord_flip() + labs( title = "Mass shootings in the United States (1982-2019)", x = "Race of perpetrator", y = "Number of incidents" )

Created on 2021-07-13 by the reprex package (v2.0.0)

Session info

annikaludwig commented 3 years ago
library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case     year month   day location summary   fatalities injured total_victims
#>    <chr>   <dbl> <chr> <int> <chr>    <chr>          <dbl>   <dbl>         <dbl>
#>  1 Dayton…  2019 Aug       4 Dayton,… "PENDING"          9      27            36
#>  2 El Pas…  2019 Aug       3 El Paso… "PENDING"         20      26            46
#>  3 Gilroy…  2019 Jul      28 Gilroy,… "Santino…          3      12            15
#>  4 Virgin…  2019 May      31 Virgini… "DeWayne…         12       4            16
#>  5 Harry …  2019 Feb      15 Aurora,… "Gary Ma…          5       6            11
#>  6 Pennsy…  2019 Jan      24 State C… "Jordan …          3       1             4
#>  7 SunTru…  2019 Jan      23 Sebring… "Zephen …          5       0             5
#>  8 Mercy …  2018 Nov      19 Chicago… "Juan Lo…          3       0             3
#>  9 Thousa…  2018 Nov       7 Thousan… "Ian Dav…         12      22            34
#> 10 Tree o…  2018 Oct      27 Pittsbu… "Robert …         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-07-13 by the reprex package (v2.0.0)

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.0.1 (2020-06-06) #> os Red Hat Enterprise Linux 8.4 (Ootpa) #> system x86_64, linux-gnu #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz America/Chicago #> date 2021-07-13 #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [2] CRAN (R 4.0.1) #> backports 1.2.1 2020-12-09 [2] CRAN (R 4.0.1) #> broom 0.7.5 2021-02-19 [2] CRAN (R 4.0.1) #> cellranger 1.1.0 2016-07-27 [2] CRAN (R 4.0.1) #> cli 2.3.1 2021-02-23 [2] CRAN (R 4.0.1) #> colorspace 2.0-0 2020-11-11 [2] CRAN (R 4.0.1) #> crayon 1.4.1 2021-02-08 [2] CRAN (R 4.0.1) #> curl 4.3 2019-12-02 [2] CRAN (R 4.0.1) #> DBI 1.1.1 2021-01-15 [2] CRAN (R 4.0.1) #> dbplyr 2.1.0 2021-02-03 [2] CRAN (R 4.0.1) #> digest 0.6.27 2020-10-24 [2] CRAN (R 4.0.1) #> dplyr * 1.0.5 2021-03-05 [2] CRAN (R 4.0.1) #> ellipsis 0.3.1 2020-05-15 [2] CRAN (R 4.0.1) #> evaluate 0.14 2019-05-28 [2] CRAN (R 4.0.1) #> fansi 0.4.2 2021-01-15 [2] CRAN (R 4.0.1) #> farver 2.1.0 2021-02-28 [2] CRAN (R 4.0.1) #> forcats * 0.5.1 2021-01-27 [2] CRAN (R 4.0.1) #> fs 1.5.0 2020-07-31 [2] CRAN (R 4.0.1) #> generics 0.1.0 2020-10-31 [2] CRAN (R 4.0.1) #> ggplot2 * 3.3.3 2020-12-30 [2] CRAN (R 4.0.1) #> glue 1.4.2 2020-08-27 [2] CRAN (R 4.0.1) #> gtable 0.3.0 2019-03-25 [2] CRAN (R 4.0.1) #> haven 2.3.1 2020-06-01 [2] CRAN (R 4.0.1) #> highr 0.8 2019-03-20 [2] CRAN (R 4.0.1) #> hms 1.0.0 2021-01-13 [2] CRAN (R 4.0.1) #> htmltools 0.5.1.1 2021-01-22 [2] CRAN (R 4.0.1) #> httr 1.4.2 2020-07-20 [2] CRAN (R 4.0.1) #> jsonlite 1.7.2 2020-12-09 [2] CRAN (R 4.0.1) #> knitr 1.31 2021-01-27 [2] CRAN (R 4.0.1) #> labeling 0.4.2 2020-10-20 [2] CRAN (R 4.0.1) #> lifecycle 1.0.0 2021-02-15 [2] CRAN (R 4.0.1) #> lubridate 1.7.10 2021-02-26 [2] CRAN (R 4.0.1) #> magrittr 2.0.1 2020-11-17 [2] CRAN (R 4.0.1) #> mime 0.10 2021-02-13 [2] CRAN (R 4.0.1) #> modelr 0.1.8 2020-05-19 [2] CRAN (R 4.0.1) #> munsell 0.5.0 2018-06-12 [2] CRAN (R 4.0.1) #> pillar 1.5.1 2021-03-05 [2] CRAN (R 4.0.1) #> pkgconfig 2.0.3 2019-09-22 [2] CRAN (R 4.0.1) #> purrr * 0.3.4 2020-04-17 [2] CRAN (R 4.0.1) #> R6 2.5.0 2020-10-28 [2] CRAN (R 4.0.1) #> rcfss * 0.2.1 2021-06-28 [1] Github (uc-cfss/rcfss@5b60f61) #> Rcpp 1.0.6 2021-01-15 [2] CRAN (R 4.0.1) #> readr * 1.4.0 2020-10-05 [2] CRAN (R 4.0.1) #> readxl 1.3.1 2019-03-13 [2] CRAN (R 4.0.1) #> reprex 2.0.0 2021-04-02 [2] CRAN (R 4.0.1) #> rlang 0.4.10 2020-12-30 [2] CRAN (R 4.0.1) #> rmarkdown 2.7 2021-02-19 [2] CRAN (R 4.0.1) #> rstudioapi 0.13 2020-11-12 [2] CRAN (R 4.0.1) #> rvest 1.0.0 2021-03-09 [2] CRAN (R 4.0.1) #> scales 1.1.1 2020-05-11 [2] CRAN (R 4.0.1) #> sessioninfo 1.1.1 2018-11-05 [2] CRAN (R 4.0.1) #> stringi 1.5.3 2020-09-09 [2] CRAN (R 4.0.1) #> stringr * 1.4.0 2019-02-10 [2] CRAN (R 4.0.1) #> styler 1.4.1 2021-03-30 [2] CRAN (R 4.0.1) #> tibble * 3.1.0 2021-02-25 [2] CRAN (R 4.0.1) #> tidyr * 1.1.3 2021-03-03 [2] CRAN (R 4.0.1) #> tidyselect 1.1.0 2020-05-11 [2] CRAN (R 4.0.1) #> tidyverse * 1.3.0 2019-11-21 [2] CRAN (R 4.0.1) #> utf8 1.2.1 2021-03-12 [2] CRAN (R 4.0.1) #> vctrs 0.3.7 2021-03-29 [2] CRAN (R 4.0.1) #> withr 2.4.1 2021-01-26 [2] CRAN (R 4.0.1) #> xfun 0.22 2021-03-11 [2] CRAN (R 4.0.1) #> xml2 1.3.2 2020-04-23 [2] CRAN (R 4.0.1) #> yaml 2.2.1 2020-02-01 [2] CRAN (R 4.0.1) #> #> [1] /home/aludwig/R/x86_64-pc-linux-gnu-library/4.0 #> [2] /opt/R/4.0.1/lib/R/library ```
bensoltoff commented 3 years ago
## Copy the code below to generate a reproducible example
## using the reprex package. Once you generate it, post it on
## https://github.com/uc-cfss/Discussion/issues/181

library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case     year month   day location summary   fatalities injured total_victims
#>    <chr>   <dbl> <chr> <int> <chr>    <chr>          <dbl>   <dbl>         <dbl>
#>  1 Dayton…  2019 Aug       4 Dayton,… "PENDING"          9      27            36
#>  2 El Pas…  2019 Aug       3 El Paso… "PENDING"         20      26            46
#>  3 Gilroy…  2019 Jul      28 Gilroy,… "Santino…          3      12            15
#>  4 Virgin…  2019 May      31 Virgini… "DeWayne…         12       4            16
#>  5 Harry …  2019 Feb      15 Aurora,… "Gary Ma…          5       6            11
#>  6 Pennsy…  2019 Jan      24 State C… "Jordan …          3       1             4
#>  7 SunTru…  2019 Jan      23 Sebring… "Zephen …          5       0             5
#>  8 Mercy …  2018 Nov      19 Chicago… "Juan Lo…          3       0             3
#>  9 Thousa…  2018 Nov       7 Thousan… "Ian Dav…         12      22            34
#> 10 Tree o…  2018 Oct      27 Pittsbu… "Robert …         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-07-13 by the reprex package (v2.0.0)

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.0.1 (2020-06-06) #> os Red Hat Enterprise Linux 8.4 (Ootpa) #> system x86_64, linux-gnu #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz America/Chicago #> date 2021-07-13 #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [2] CRAN (R 4.0.1) #> backports 1.2.1 2020-12-09 [2] CRAN (R 4.0.1) #> broom 0.7.5 2021-02-19 [2] CRAN (R 4.0.1) #> cellranger 1.1.0 2016-07-27 [2] CRAN (R 4.0.1) #> cli 2.5.0 2021-04-26 [1] CRAN (R 4.0.1) #> colorspace 2.0-0 2020-11-11 [2] CRAN (R 4.0.1) #> crayon 1.4.1 2021-02-08 [2] CRAN (R 4.0.1) #> curl 4.3.1 2021-04-30 [1] CRAN (R 4.0.1) #> DBI 1.1.1 2021-01-15 [2] CRAN (R 4.0.1) #> dbplyr 2.1.0 2021-02-03 [2] CRAN (R 4.0.1) #> digest 0.6.27 2020-10-24 [2] CRAN (R 4.0.1) #> dplyr * 1.0.7 2021-06-18 [1] CRAN (R 4.0.1) #> ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.0.1) #> evaluate 0.14 2019-05-28 [2] CRAN (R 4.0.1) #> fansi 0.5.0 2021-05-25 [1] CRAN (R 4.0.1) #> farver 2.1.0 2021-02-28 [2] CRAN (R 4.0.1) #> forcats * 0.5.1 2021-01-27 [2] CRAN (R 4.0.1) #> fs 1.5.0 2020-07-31 [2] CRAN (R 4.0.1) #> generics 0.1.0 2020-10-31 [2] CRAN (R 4.0.1) #> ggplot2 * 3.3.3 2020-12-30 [2] CRAN (R 4.0.1) #> glue 1.4.2 2020-08-27 [2] CRAN (R 4.0.1) #> gtable 0.3.0 2019-03-25 [2] CRAN (R 4.0.1) #> haven 2.3.1 2020-06-01 [2] CRAN (R 4.0.1) #> highr 0.8 2019-03-20 [2] CRAN (R 4.0.1) #> hms 1.0.0 2021-01-13 [2] CRAN (R 4.0.1) #> htmltools 0.5.1.1 2021-01-22 [2] CRAN (R 4.0.1) #> httr 1.4.2 2020-07-20 [2] CRAN (R 4.0.1) #> jsonlite 1.7.2 2020-12-09 [2] CRAN (R 4.0.1) #> knitr 1.31 2021-01-27 [2] CRAN (R 4.0.1) #> labeling 0.4.2 2020-10-20 [2] CRAN (R 4.0.1) #> lifecycle 1.0.0 2021-02-15 [2] CRAN (R 4.0.1) #> lubridate 1.7.10 2021-02-26 [2] CRAN (R 4.0.1) #> magrittr 2.0.1 2020-11-17 [2] CRAN (R 4.0.1) #> mime 0.10 2021-02-13 [2] CRAN (R 4.0.1) #> modelr 0.1.8 2020-05-19 [2] CRAN (R 4.0.1) #> munsell 0.5.0 2018-06-12 [2] CRAN (R 4.0.1) #> pillar 1.6.1 2021-05-16 [1] CRAN (R 4.0.1) #> pkgconfig 2.0.3 2019-09-22 [2] CRAN (R 4.0.1) #> purrr * 0.3.4 2020-04-17 [2] CRAN (R 4.0.1) #> R6 2.5.0 2020-10-28 [2] CRAN (R 4.0.1) #> rcfss * 0.2.1 2021-04-02 [2] Github (uc-cfss/rcfss@4d9144d) #> Rcpp 1.0.6 2021-01-15 [2] CRAN (R 4.0.1) #> readr * 1.4.0 2020-10-05 [2] CRAN (R 4.0.1) #> readxl 1.3.1 2019-03-13 [2] CRAN (R 4.0.1) #> reprex 2.0.0 2021-04-02 [2] CRAN (R 4.0.1) #> rlang 0.4.11 2021-04-30 [1] CRAN (R 4.0.1) #> rmarkdown 2.9 2021-06-15 [1] CRAN (R 4.0.1) #> rstudioapi 0.13 2020-11-12 [2] CRAN (R 4.0.1) #> rvest 1.0.0 2021-03-09 [2] CRAN (R 4.0.1) #> scales 1.1.1 2020-05-11 [2] CRAN (R 4.0.1) #> sessioninfo 1.1.1 2018-11-05 [2] CRAN (R 4.0.1) #> stringi 1.5.3 2020-09-09 [2] CRAN (R 4.0.1) #> stringr * 1.4.0 2019-02-10 [2] CRAN (R 4.0.1) #> styler 1.4.1 2021-03-30 [2] CRAN (R 4.0.1) #> tibble * 3.1.2 2021-05-16 [1] CRAN (R 4.0.1) #> tidyr * 1.1.3 2021-03-03 [2] CRAN (R 4.0.1) #> tidyselect 1.1.1 2021-04-30 [1] CRAN (R 4.0.1) #> tidyverse * 1.3.0 2019-11-21 [2] CRAN (R 4.0.1) #> utf8 1.2.1 2021-03-12 [2] CRAN (R 4.0.1) #> vctrs 0.3.8 2021-04-29 [1] CRAN (R 4.0.1) #> withr 2.4.2 2021-04-18 [1] CRAN (R 4.0.1) #> xfun 0.22 2021-03-11 [2] CRAN (R 4.0.1) #> xml2 1.3.2 2020-04-23 [2] CRAN (R 4.0.1) #> yaml 2.2.1 2020-02-01 [2] CRAN (R 4.0.1) #> #> [1] /home/soltoffbc/R/x86_64-pc-linux-gnu-library/4.0 #> [2] /opt/R/4.0.1/lib/R/library ```
ktakaira commented 3 years ago
## Copy the code below to generate a reproducible example
## using the reprex package. Once you generate it, post it on
## https://github.com/uc-cfss/Discussion/issues/181

library(tidyverse)

# get data from rcfss package
# install latest version if not already installed
# devtools::install_github("uc-cfss/rcfss")
library(rcfss)

# load the data
data("mass_shootings")
mass_shootings
#> # A tibble: 114 x 14
#>    case     year month   day location summary   fatalities injured total_victims
#>    <chr>   <dbl> <chr> <int> <chr>    <chr>          <dbl>   <dbl>         <dbl>
#>  1 Dayton…  2019 Aug       4 Dayton,… "PENDING"          9      27            36
#>  2 El Pas…  2019 Aug       3 El Paso… "PENDING"         20      26            46
#>  3 Gilroy…  2019 Jul      28 Gilroy,… "Santino…          3      12            15
#>  4 Virgin…  2019 May      31 Virgini… "DeWayne…         12       4            16
#>  5 Harry …  2019 Feb      15 Aurora,… "Gary Ma…          5       6            11
#>  6 Pennsy…  2019 Jan      24 State C… "Jordan …          3       1             4
#>  7 SunTru…  2019 Jan      23 Sebring… "Zephen …          5       0             5
#>  8 Mercy …  2018 Nov      19 Chicago… "Juan Lo…          3       0             3
#>  9 Thousa…  2018 Nov       7 Thousan… "Ian Dav…         12      22            34
#> 10 Tree o…  2018 Oct      27 Pittsbu… "Robert …         11       6            17
#> # … with 104 more rows, and 5 more variables: location_type <chr>, male <lgl>,
#> #   age_of_shooter <dbl>, race <chr>, prior_mental_illness <chr>

# Generate a bar chart that identifies the number of mass shooters
# associated with each race category. The bars should be sorted
# from highest to lowest.

# using forcats::fct_infreq() and using the raw data for plotting
mass_shootings %>%
  drop_na(race) %>%
  ggplot(mapping = aes(x = fct_infreq(race))) +
  geom_bar() +
  coord_flip() +
  labs(
    title = "Mass shootings in the United States (1982-2019)",
    x = "Race of perpetrator",
    y = "Number of incidents"
  )

Created on 2021-07-13 by the reprex package (v2.0.0)