In this markdown document for AAEC 8610 Homework 2, I imported the data about suicide attempts in Shandong Province, China from 2019 to 2011.

1. Table of Summary Statistics

I created a table of summary statistics for some categorical variables of interest:

library(Stat2Data)
data(SuicideChina)
library(vtable)
## Loading required package: kableExtra
st(SuicideChina, vars = c('Hospitalised','Died','Urban','Sex','Education','Occupation','method'), 
   title = "Table 1. Summary statistics", col.breaks = c(4.15))
Table 1. Summary statistics
Variable N Percent Variable N Percent
Hospitalised 2571 Education 2571
… no 1018 39.6% … iliterate 533 20.7%
… yes 1553 60.4% … primary 659 25.6%
Died 2571 … Secondary 1280 49.8%
… no 1315 51.1% … Tertiary 19 0.7%
… yes 1256 48.9% … unknown 80 3.1%
Urban 2571 Occupation 2571
… no 2213 86.1% … business/service 21 0.8%
… unknown 81 3.2% … farming 2032 79%
… yes 277 10.8% … household 248 9.6%
Sex 2571 … others 3 0.1%
… female 1328 51.7% … others/unknown 156 6.1%
… male 1243 48.3% … professional 37 1.4%
… retiree 3 0.1%
… student 35 1.4%
… unemployed 30 1.2%
… worker 6 0.2%

2. One number computed using inline r code

sum(is.na(SuicideChina))
## [1] 0

There is no missing value in the data.

3. Histogram of suicide counts by age

library("ggplot2")
plot_1 <- ggplot(data = SuicideChina, mapping = aes(x = Age)) + 
  geom_histogram (fill = "steelblue2", color = "black", binwidth = 5) + 
  labs(x = "age", y = "count", title = "Plot 1: Distribution of suicide attempt counts by age from 2019 to 2011",
       caption = "Data source: SuicideChina") + 
  theme(plot.title = element_text(hjust = 0.5, face = "bold"),
        plot.caption = element_text(size = 12),
        axis.text.x=element_text(size = 12), 
        axis.text.y=element_text(size = 12), 
        axis.title = element_text(size = 15))
print(plot_1)