PROJECT # 1

Josue Ramirez

Children under 18 are suffering from cancer

My data set is about the cancer rates in people under 18 years of age across the country. This is my data set from https://corgis-edu.github.io/corgis/csv/cancer/. My quantitative data are Age-specific death rates (under 18) and population size. My categorical data are state and cancer type. This project helps spread awareness of the young people who are dying of cancer across different states. Some states have higher rate of death due to population sizes so it is important to keep that in mind.

# Chunk 1: Load the package and the package has the tools needed for this dataset.dsf
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.2.1     ✔ readr     2.2.0
✔ forcats   1.0.1     ✔ stringr   1.6.0
✔ ggplot2   4.0.3     ✔ tibble    3.3.1
✔ lubridate 1.9.5     ✔ tidyr     1.3.2
✔ purrr     1.2.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
#Chunk 2: Imports the dataset "cancer"
cancer <- read_csv("/Users/josue/Downloads/Data110_Summer/cancer.csv")
Rows: 51 Columns: 75
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr  (1): State
dbl (74): Total.Rate, Total.Number, Total.Population, Rates.Age.< 18, Rates....

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#Chunk 3: This chunk displays the variables,overview, and summarizes each variable of the dataset.
str(cancer)
spc_tbl_ [51 × 75] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
 $ State                                       : chr [1:51] "Alabama" "Alaska" "Arizona" "Arkansas" ...
 $ Total.Rate                                  : num [1:51] 214 128 166 224 151 ...
 $ Total.Number                                : num [1:51] 71529 6361 74286 45627 393980 ...
 $ Total.Population                            : num [1:51] 3.34e+07 4.97e+06 4.48e+07 2.04e+07 2.61e+08 ...
 $ Rates.Age.< 18                              : num [1:51] 2 1.7 2.5 2.3 2.6 1.9 1.6 2.2 0 2.1 ...
 $ Rates.Age.18-45                             : num [1:51] 18.5 11.8 13.6 17.6 13.7 11.7 13.6 16 12.4 15.9 ...
 $ Rates.Age.45-64                             : num [1:51] 245 171 174 250 164 ...
 $ Rates.Age.> 64                              : num [1:51] 1018 965 840 1048 902 ...
 $ Rates.Age and Sex.Female.< 18               : num [1:51] 2 0 2.6 2.6 2.4 1.9 1.6 0 0 2 ...
 $ Rates.Age and Sex.Male.< 18                 : num [1:51] 2.1 0 2.5 2 2.8 1.9 1.7 0 0 2.2 ...
 $ Rates.Age and Sex.Female.18 - 45            : num [1:51] 20.1 13.9 15.2 19.5 15 12.8 15.1 17.8 13.9 17.5 ...
 $ Rates.Age and Sex.Male.18 - 45              : num [1:51] 16.8 10 12.2 15.8 12.5 10.7 12.1 14.2 10.8 14.4 ...
 $ Rates.Age and Sex.Female.45 - 64            : num [1:51] 201 158 156 212 156 ...
 $ Rates.Age and Sex.Male.45 - 64              : num [1:51] 292 183 192 290 172 ...
 $ Rates.Age and Sex.Female.> 64               : num [1:51] 804 850 706 838 775 ...
 $ Rates.Age and Sex.Male.> 64                 : num [1:51] 1309 1086 1000 1320 1067 ...
 $ Rates.Race.White                            : num [1:51] 186 168 154 192 161 ...
 $ Rates.Race.White non-Hispanic               : num [1:51] 188 170 156 194 170 ...
 $ Rates.Race.Black                            : num [1:51] 216 184 167 228 197 ...
 $ Rates.Race.Asian                            : num [1:51] 81.3 118.7 93 115.9 112.4 ...
 $ Rates.Race.Indigenous                       : num [1:51] 69.9 247.2 116.2 59.2 77 ...
 $ Rates.Race and Sex.Female.White             : num [1:51] 149 146 131 156 141 ...
 $ Rates.Race and Sex.Female.White non-Hispanic: num [1:51] 150 148 134 158 150 ...
 $ Rates.Race and Sex.Female.Black             : num [1:51] 167 142 146 180 172 ...
 $ Rates.Race and Sex.Female.Black non-Hispanic: num [1:51] 168 149 154 180 180 ...
 $ Rates.Race and Sex.Female.Asian             : num [1:51] 84.9 105.2 80.6 91.7 96.1 ...
 $ Rates.Race and Sex.Female.Indigenous        : num [1:51] 53.8 219.4 100.5 44.8 65.9 ...
 $ Rates.Race and Sex.Male.White               : num [1:51] 237 196 182 240 189 ...
 $ Rates.Race and Sex.Male.White non-Hispanic  : num [1:51] 239 197 185 243 198 ...
 $ Rates.Race and Sex.Male.Black               : num [1:51] 298 241 195 305 238 ...
 $ Rates.Race and Sex.Male.Black non-Hispanic  : num [1:51] 299 247 205 305 248 ...
 $ Rates.Race and Sex.Male.Asian               : num [1:51] 75.7 142.8 112.5 157.7 135.5 ...
 $ Rates.Race and Sex.Male.Indigenous          : num [1:51] 88.3 284.9 139.5 74.8 91.3 ...
 $ Rates.Race.Hispanic                         : num [1:51] 66.5 88.8 128.5 81.2 120.9 ...
 $ Rates.Race and Sex.Female.Hispanic          : num [1:51] 58.3 73.1 106.5 74.6 103.2 ...
 $ Rates.Race and Sex.Male.Hispanic            : num [1:51] 77.1 104 158.4 90.1 146.6 ...
 $ Types.Breast.Total                          : num [1:51] 27.4 17.8 23.3 27.9 23 20.7 26.7 28 31.3 28.7 ...
 $ Types.Breast.Age.18 - 44                    : num [1:51] 5.1 2.9 3.8 5 4 3.1 4.2 4.9 3.4 4.7 ...
 $ Types.Breast.Age.45 - 64                    : num [1:51] 39.8 27.8 33.2 38.4 34.6 29.3 30.8 37.3 56.6 35.9 ...
 $ Types.Breast.Age.> 64                       : num [1:51] 95.7 108 90.5 100.6 98.6 ...
 $ Types.Breast.Race.White                     : num [1:51] 20.5 21.3 20.4 21.7 22.2 19.5 20.2 22.5 23.2 20.1 ...
 $ Types.Breast.Race.White non-Hispanic        : num [1:51] 20.6 21.8 20.9 22 24.3 19.8 20.6 22.8 25.2 21.2 ...
 $ Types.Breast.Race.Black                     : num [1:51] 30.3 0 26.3 31.1 31.3 24.9 23.8 25.5 34.6 27.3 ...
 $ Types.Breast.Race.Black non-Hispanic        : num [1:51] 30.4 0 28 31 33.1 26 25.4 25.8 34.6 28.4 ...
 $ Types.Breast.Race.Asian                     : num [1:51] 0 12.2 10.7 0 12.8 9.1 9.1 0 0 9.6 ...
 $ Types.Breast.Race.Indigenous                : num [1:51] 0 25.5 11.4 0 7.5 12.1 0 0 0 0 ...
 $ Types.Breast.Race.Hispanic                  : num [1:51] 0 0 16.2 10.9 15.1 15.3 11.1 0 0 15 ...
 $ Types.Colorectal.Total                      : num [1:51] 19.4 11.9 14.9 21.2 14 12.7 15.6 17.6 17.5 19.6 ...
 $ Types.Colorectal.Age and Sex.Female.18 - 44 : num [1:51] 1.6 0 1.3 1.9 1.2 1 1.2 0 0 1.4 ...
 $ Types.Colorectal.Age and Sex.Male.18 - 44   : num [1:51] 2.3 0 1.4 2.2 1.4 1.1 1.5 1.8 0 1.8 ...
 $ Types.Colorectal.Age and Sex.Female.45 - 64 : num [1:51] 18 15.3 12.6 19.7 13.4 11.6 10.5 13 21.9 15.1 ...
 $ Types.Colorectal.Age and Sex.Male.45 - 64   : num [1:51] 28.7 17.6 19.2 28.6 17.9 15.7 15.6 23.1 25.3 22.7 ...
 $ Types.Colorectal.Age and Sex.Female.> 64    : num [1:51] 78.4 71.7 67.6 85.8 75.3 73.5 76.9 77.1 98.9 71 ...
 $ Types.Colorectal.Age and Sex.Male.> 64      : num [1:51] 106 102.3 85.2 114.4 93.3 ...
 $ Types.Colorectal.Race.White                 : num [1:51] 15.9 13.6 13.8 17.7 14.4 13.4 12.8 15.4 10 14.3 ...
 $ Types.Colorectal.Race.White non-Hispanic    : num [1:51] 16 13.8 13.9 17.9 15 13.1 12.9 15.4 9.8 14.5 ...
 $ Types.Colorectal.Race.Black                 : num [1:51] 24.4 0 18.7 26.3 21.2 17.2 15.5 16.9 23 18.5 ...
 $ Types.Colorectal.Race.Black non-Hispanic    : num [1:51] 24.5 0 19.7 26.4 22.2 17.9 16.4 17 23.1 19.2 ...
 $ Types.Colorectal.Race.Asian                 : num [1:51] 0 12.5 10.6 0 11.6 10.7 6.6 0 0 9.2 ...
 $ Types.Colorectal.Race.Indigenous            : num [1:51] 0 34.7 10.1 0 7.7 7.6 0 0 0 5.6 ...
 $ Types.Colorectal.Race.Hispanic              : num [1:51] 5.7 0 13.1 8.1 11.7 14.8 10.2 0 9.1 13.4 ...
 $ Types.Lung.Total                            : num [1:51] 66.4 36.6 42.3 73.3 34.5 31.8 49 62.7 41.6 63 ...
 $ Types.Lung.Age and Sex.Female.18 - 44       : num [1:51] 1.7 0 1.1 1.9 0.8 0.7 1.5 0 0 1.6 ...
 $ Types.Lung.Age and Sex.Male.18 - 44         : num [1:51] 2.4 0 0.8 1.8 0.8 0.7 1.3 2.1 0 1.5 ...
 $ Types.Lung.Age and Sex.Female.45 - 64       : num [1:51] 54.8 39.7 33.2 61.4 28.4 27.8 37.3 55.6 51.3 47.5 ...
 $ Types.Lung.Age and Sex.Male.45 - 64         : num [1:51] 102.9 50.3 47 106.5 36.8 ...
 $ Types.Lung.Age and Sex.Female.> 64          : num [1:51] 222 268 192 249 192 ...
 $ Types.Lung.Age and Sex.Male.> 64            : num [1:51] 457 335 276 485 269 ...
 $ Types.Lung.Race.White                       : num [1:51] 59.9 48.7 39.5 63.4 37.2 34.1 42.2 55 27.3 48 ...
 $ Types.Lung.Race.White non-Hispanic          : num [1:51] 60.4 49.5 42.2 64.2 42.6 35 43.2 55.7 27.6 52.5 ...
 $ Types.Lung.Race.Black                       : num [1:51] 52.6 45.6 38.2 62.9 46.5 40.4 38.4 49.3 53.6 38.1 ...
 $ Types.Lung.Race.Black non-Hispanic          : num [1:51] 52.8 47.9 40.4 63 48.6 41.5 40.4 49.8 54.2 39.5 ...
 $ Types.Lung.Race.Asian                       : num [1:51] 23 33 21.3 18.1 25.8 22.8 20.8 23.7 0 19.8 ...
 $ Types.Lung.Race.Indigenous                  : num [1:51] 22.9 74.4 11.1 16.2 18.4 22.3 0 0 0 21 ...
 $ Types.Lung.Race.Hispanic                    : num [1:51] 14.8 0 21.6 14.6 18.3 25.6 20.3 15.5 18.8 24 ...
 - attr(*, "spec")=
  .. cols(
  ..   State = col_character(),
  ..   Total.Rate = col_double(),
  ..   Total.Number = col_double(),
  ..   Total.Population = col_double(),
  ..   `Rates.Age.< 18` = col_double(),
  ..   `Rates.Age.18-45` = col_double(),
  ..   `Rates.Age.45-64` = col_double(),
  ..   `Rates.Age.> 64` = col_double(),
  ..   `Rates.Age and Sex.Female.< 18` = col_double(),
  ..   `Rates.Age and Sex.Male.< 18` = col_double(),
  ..   `Rates.Age and Sex.Female.18 - 45` = col_double(),
  ..   `Rates.Age and Sex.Male.18 - 45` = col_double(),
  ..   `Rates.Age and Sex.Female.45 - 64` = col_double(),
  ..   `Rates.Age and Sex.Male.45 - 64` = col_double(),
  ..   `Rates.Age and Sex.Female.> 64` = col_double(),
  ..   `Rates.Age and Sex.Male.> 64` = col_double(),
  ..   Rates.Race.White = col_double(),
  ..   `Rates.Race.White non-Hispanic` = col_double(),
  ..   Rates.Race.Black = col_double(),
  ..   Rates.Race.Asian = col_double(),
  ..   Rates.Race.Indigenous = col_double(),
  ..   `Rates.Race and Sex.Female.White` = col_double(),
  ..   `Rates.Race and Sex.Female.White non-Hispanic` = col_double(),
  ..   `Rates.Race and Sex.Female.Black` = col_double(),
  ..   `Rates.Race and Sex.Female.Black non-Hispanic` = col_double(),
  ..   `Rates.Race and Sex.Female.Asian` = col_double(),
  ..   `Rates.Race and Sex.Female.Indigenous` = col_double(),
  ..   `Rates.Race and Sex.Male.White` = col_double(),
  ..   `Rates.Race and Sex.Male.White non-Hispanic` = col_double(),
  ..   `Rates.Race and Sex.Male.Black` = col_double(),
  ..   `Rates.Race and Sex.Male.Black non-Hispanic` = col_double(),
  ..   `Rates.Race and Sex.Male.Asian` = col_double(),
  ..   `Rates.Race and Sex.Male.Indigenous` = col_double(),
  ..   Rates.Race.Hispanic = col_double(),
  ..   `Rates.Race and Sex.Female.Hispanic` = col_double(),
  ..   `Rates.Race and Sex.Male.Hispanic` = col_double(),
  ..   Types.Breast.Total = col_double(),
  ..   `Types.Breast.Age.18 - 44` = col_double(),
  ..   `Types.Breast.Age.45 - 64` = col_double(),
  ..   `Types.Breast.Age.> 64` = col_double(),
  ..   Types.Breast.Race.White = col_double(),
  ..   `Types.Breast.Race.White non-Hispanic` = col_double(),
  ..   Types.Breast.Race.Black = col_double(),
  ..   `Types.Breast.Race.Black non-Hispanic` = col_double(),
  ..   Types.Breast.Race.Asian = col_double(),
  ..   Types.Breast.Race.Indigenous = col_double(),
  ..   Types.Breast.Race.Hispanic = col_double(),
  ..   Types.Colorectal.Total = col_double(),
  ..   `Types.Colorectal.Age and Sex.Female.18 - 44` = col_double(),
  ..   `Types.Colorectal.Age and Sex.Male.18 - 44` = col_double(),
  ..   `Types.Colorectal.Age and Sex.Female.45 - 64` = col_double(),
  ..   `Types.Colorectal.Age and Sex.Male.45 - 64` = col_double(),
  ..   `Types.Colorectal.Age and Sex.Female.> 64` = col_double(),
  ..   `Types.Colorectal.Age and Sex.Male.> 64` = col_double(),
  ..   Types.Colorectal.Race.White = col_double(),
  ..   `Types.Colorectal.Race.White non-Hispanic` = col_double(),
  ..   Types.Colorectal.Race.Black = col_double(),
  ..   `Types.Colorectal.Race.Black non-Hispanic` = col_double(),
  ..   Types.Colorectal.Race.Asian = col_double(),
  ..   Types.Colorectal.Race.Indigenous = col_double(),
  ..   Types.Colorectal.Race.Hispanic = col_double(),
  ..   Types.Lung.Total = col_double(),
  ..   `Types.Lung.Age and Sex.Female.18 - 44` = col_double(),
  ..   `Types.Lung.Age and Sex.Male.18 - 44` = col_double(),
  ..   `Types.Lung.Age and Sex.Female.45 - 64` = col_double(),
  ..   `Types.Lung.Age and Sex.Male.45 - 64` = col_double(),
  ..   `Types.Lung.Age and Sex.Female.> 64` = col_double(),
  ..   `Types.Lung.Age and Sex.Male.> 64` = col_double(),
  ..   Types.Lung.Race.White = col_double(),
  ..   `Types.Lung.Race.White non-Hispanic` = col_double(),
  ..   Types.Lung.Race.Black = col_double(),
  ..   `Types.Lung.Race.Black non-Hispanic` = col_double(),
  ..   Types.Lung.Race.Asian = col_double(),
  ..   Types.Lung.Race.Indigenous = col_double(),
  ..   Types.Lung.Race.Hispanic = col_double()
  .. )
 - attr(*, "problems")=<pointer: 0x131e2bab0> 
summary(cancer)
       State      Total.Rate     Total.Number    Total.Population   
 Length   :51   Min.   : 98.5   Min.   :  6361   Min.   :  3931624  
 N.unique :51   1st Qu.:176.5   1st Qu.: 20631   1st Qu.: 11869910  
 N.blank  : 0   Median :196.1   Median : 54930   Median : 30348057  
 Min.nchar: 4   Mean   :190.7   Mean   : 78724   Mean   : 42401511  
 Max.nchar:20   3rd Qu.:210.8   3rd Qu.: 93328   3rd Qu.: 46503256  
                Max.   :254.6   Max.   :393980   Max.   :261135696  
 Rates.Age.< 18 Rates.Age.18-45 Rates.Age.45-64 Rates.Age.> 64  
 Min.   :0.00   Min.   :10.00   Min.   :132.3   Min.   : 735.8  
 1st Qu.:2.05   1st Qu.:13.35   1st Qu.:175.0   1st Qu.: 943.5  
 Median :2.20   Median :14.60   Median :189.3   Median : 999.6  
 Mean   :2.12   Mean   :14.76   Mean   :197.6   Mean   : 980.9  
 3rd Qu.:2.40   3rd Qu.:16.25   3rd Qu.:217.8   3rd Qu.:1031.5  
 Max.   :2.70   Max.   :20.30   Max.   :263.9   Max.   :1110.2  
 Rates.Age and Sex.Female.< 18 Rates.Age and Sex.Male.< 18
 Min.   :0.000                 Min.   :0.000              
 1st Qu.:1.750                 1st Qu.:2.050              
 Median :2.000                 Median :2.300              
 Mean   :1.727                 Mean   :2.033              
 3rd Qu.:2.200                 3rd Qu.:2.500              
 Max.   :2.900                 Max.   :3.200              
 Rates.Age and Sex.Female.18 - 45 Rates.Age and Sex.Male.18 - 45
 Min.   :10.30                    Min.   : 9.80                 
 1st Qu.:14.15                    1st Qu.:12.40                 
 Median :16.00                    Median :13.40                 
 Mean   :16.01                    Mean   :13.55                 
 3rd Qu.:17.70                    3rd Qu.:14.35                 
 Max.   :22.80                    Max.   :19.00                 
 Rates.Age and Sex.Female.45 - 64 Rates.Age and Sex.Male.45 - 64
 Min.   :126.1                    Min.   :138.5                 
 1st Qu.:162.9                    1st Qu.:187.8                 
 Median :172.2                    Median :208.3                 
 Mean   :177.8                    Mean   :218.3                 
 3rd Qu.:193.3                    3rd Qu.:243.3                 
 Max.   :233.2                    Max.   :310.0                 
 Rates.Age and Sex.Female.> 64 Rates.Age and Sex.Male.> 64 Rates.Race.White
 Min.   :611.6                 Min.   : 884.9              Min.   :127.8   
 1st Qu.:803.5                 1st Qu.:1112.8              1st Qu.:162.8   
 Median :845.5                 Median :1195.0              Median :171.3   
 Mean   :826.7                 Mean   :1181.8              Mean   :171.0   
 3rd Qu.:871.1                 3rd Qu.:1257.8              3rd Qu.:180.2   
 Max.   :916.2                 Max.   :1372.7              Max.   :204.9   
 Rates.Race.White non-Hispanic Rates.Race.Black Rates.Race.Asian
 Min.   :129.1                 Min.   :  0.0    Min.   :  0.00  
 1st Qu.:165.7                 1st Qu.:162.6    1st Qu.: 90.65  
 Median :173.9                 Median :194.4    Median : 97.60  
 Mean   :173.2                 Mean   :182.8    Mean   : 98.99  
 3rd Qu.:183.4                 3rd Qu.:220.8    3rd Qu.:112.65  
 Max.   :205.9                 Max.   :235.1    Max.   :149.00  
 Rates.Race.Indigenous Rates.Race and Sex.Female.White
 Min.   :  0.00        Min.   :109.9                  
 1st Qu.: 57.95        1st Qu.:140.4                  
 Median :102.20        Median :146.2                  
 Mean   :111.11        Mean   :145.6                  
 3rd Qu.:162.05        3rd Qu.:152.4                  
 Max.   :248.00        Max.   :170.5                  
 Rates.Race and Sex.Female.White non-Hispanic Rates.Race and Sex.Female.Black
 Min.   :110.5                                Min.   :  0.0                  
 1st Qu.:143.6                                1st Qu.:135.7                  
 Median :149.9                                Median :161.7                  
 Mean   :147.7                                Mean   :142.7                  
 3rd Qu.:155.2                                3rd Qu.:181.7                  
 Max.   :171.2                                Max.   :195.6                  
 Rates.Race and Sex.Female.Black non-Hispanic Rates.Race and Sex.Female.Asian
 Min.   :  0.0                                Min.   :  0.00                 
 1st Qu.:146.3                                1st Qu.: 79.50                 
 Median :165.6                                Median : 85.60                 
 Mean   :146.6                                Mean   : 85.01                 
 3rd Qu.:182.8                                3rd Qu.: 94.80                 
 Max.   :198.5                                Max.   :130.30                 
 Rates.Race and Sex.Female.Indigenous Rates.Race and Sex.Male.White
 Min.   :  0.00                       Min.   :145.1                
 1st Qu.: 43.70                       1st Qu.:195.4                
 Median : 78.70                       Median :205.4                
 Mean   : 88.71                       Mean   :206.4                
 3rd Qu.:127.65                       3rd Qu.:218.2                
 Max.   :219.40                       Max.   :253.6                
 Rates.Race and Sex.Male.White non-Hispanic Rates.Race and Sex.Male.Black
 Min.   :146.2                              Min.   :  0.0                
 1st Qu.:197.0                              1st Qu.:200.1                
 Median :207.8                              Median :246.2                
 Mean   :208.7                              Mean   :222.9                
 3rd Qu.:220.2                              3rd Qu.:278.7                
 Max.   :255.1                              Max.   :319.5                
 Rates.Race and Sex.Male.Black non-Hispanic Rates.Race and Sex.Male.Asian
 Min.   :  0.0                              Min.   :  0.00               
 1st Qu.:216.6                              1st Qu.: 96.45               
 Median :252.7                              Median :112.50               
 Mean   :228.2                              Mean   :107.22               
 3rd Qu.:282.1                              3rd Qu.:129.15               
 Max.   :321.2                              Max.   :172.20               
 Rates.Race and Sex.Male.Indigenous Rates.Race.Hispanic
 Min.   :  0.0                      Min.   : 39.50     
 1st Qu.: 66.6                      1st Qu.: 82.40     
 Median :114.2                      Median : 98.00     
 Mean   :129.6                      Mean   : 98.16     
 3rd Qu.:198.3                      3rd Qu.:112.15     
 Max.   :303.3                      Max.   :168.50     
 Rates.Race and Sex.Female.Hispanic Rates.Race and Sex.Male.Hispanic
 Min.   :  0.00                     Min.   :  0.0                   
 1st Qu.: 72.55                     1st Qu.: 91.5                   
 Median : 84.80                     Median :119.4                   
 Mean   : 82.20                     Mean   :115.5                   
 3rd Qu.: 95.50                     3rd Qu.:136.9                   
 Max.   :140.80                     Max.   :202.3                   
 Types.Breast.Total Types.Breast.Age.18 - 44 Types.Breast.Age.45 - 64
 Min.   :17.40      Min.   :0.000            Min.   :27.80           
 1st Qu.:24.45      1st Qu.:3.550            1st Qu.:31.20           
 Median :26.60      Median :4.200            Median :34.60           
 Mean   :26.01      Mean   :4.016            Mean   :34.89           
 3rd Qu.:27.65      3rd Qu.:4.700            3rd Qu.:37.65           
 Max.   :31.80      Max.   :5.600            Max.   :56.60           
 Types.Breast.Age.> 64 Types.Breast.Race.White
 Min.   : 62.30        Min.   :17.5           
 1st Qu.: 98.65        1st Qu.:20.4           
 Median :102.20        Median :21.1           
 Mean   :102.25        Mean   :21.2           
 3rd Qu.:107.85        3rd Qu.:22.1           
 Max.   :129.60        Max.   :24.0           
 Types.Breast.Race.White non-Hispanic Types.Breast.Race.Black
 Min.   :18.20                        Min.   : 0.00          
 1st Qu.:20.75                        1st Qu.:21.15          
 Median :21.40                        Median :27.40          
 Mean   :21.62                        Mean   :22.57          
 3rd Qu.:22.25                        3rd Qu.:31.10          
 Max.   :25.50                        Max.   :34.70          
 Types.Breast.Race.Black non-Hispanic Types.Breast.Race.Asian
 Min.   : 0.00                        Min.   : 0.000         
 1st Qu.:23.60                        1st Qu.: 0.000         
 Median :28.40                        Median : 8.500         
 Mean   :23.19                        Mean   : 6.016         
 3rd Qu.:31.85                        3rd Qu.:10.700         
 Max.   :35.00                        Max.   :15.800         
 Types.Breast.Race.Indigenous Types.Breast.Race.Hispanic Types.Colorectal.Total
 Min.   : 0.000               Min.   : 0.000             Min.   : 9.00         
 1st Qu.: 0.000               1st Qu.: 0.000             1st Qu.:16.05         
 Median : 0.000               Median :10.500             Median :17.70         
 Mean   : 4.984               Mean   : 8.557             Mean   :17.50         
 3rd Qu.:10.600               3rd Qu.:12.250             3rd Qu.:19.40         
 Max.   :27.400               Max.   :18.200             Max.   :24.40         
 Types.Colorectal.Age and Sex.Female.18 - 44
 Min.   :0.000                              
 1st Qu.:1.000                              
 Median :1.300                              
 Mean   :1.135                              
 3rd Qu.:1.500                              
 Max.   :2.000                              
 Types.Colorectal.Age and Sex.Male.18 - 44
 Min.   :0.000                            
 1st Qu.:1.400                            
 Median :1.700                            
 Mean   :1.504                            
 3rd Qu.:1.850                            
 Max.   :3.000                            
 Types.Colorectal.Age and Sex.Female.45 - 64
 Min.   :10.10                              
 1st Qu.:13.15                              
 Median :14.30                              
 Mean   :14.71                              
 3rd Qu.:15.30                              
 Max.   :21.90                              
 Types.Colorectal.Age and Sex.Male.45 - 64
 Min.   :14.50                            
 1st Qu.:18.20                            
 Median :21.00                            
 Mean   :21.35                            
 3rd Qu.:23.50                            
 Max.   :34.10                            
 Types.Colorectal.Age and Sex.Female.> 64
 Min.   :59.70                           
 1st Qu.:74.55                           
 Median :82.40                           
 Mean   :81.80                           
 3rd Qu.:88.70                           
 Max.   :99.80                           
 Types.Colorectal.Age and Sex.Male.> 64 Types.Colorectal.Race.White
 Min.   : 72.40                         Min.   :10.00              
 1st Qu.: 93.35                         1st Qu.:14.30              
 Median :102.10                         Median :15.20              
 Mean   :101.45                         Mean   :15.23              
 3rd Qu.:110.70                         3rd Qu.:16.60              
 Max.   :124.60                         Max.   :19.10              
 Types.Colorectal.Race.White non-Hispanic Types.Colorectal.Race.Black
 Min.   : 9.80                            Min.   : 0.00              
 1st Qu.:14.50                            1st Qu.:15.05              
 Median :15.20                            Median :21.20              
 Mean   :15.35                            Mean   :17.01              
 3rd Qu.:16.70                            3rd Qu.:23.20              
 Max.   :19.20                            Max.   :26.70              
 Types.Colorectal.Race.Black non-Hispanic Types.Colorectal.Race.Asian
 Min.   : 0.00                            Min.   : 0.000             
 1st Qu.:16.35                            1st Qu.: 0.000             
 Median :21.50                            Median : 9.100             
 Mean   :17.45                            Mean   : 6.951             
 3rd Qu.:23.50                            3rd Qu.:10.650             
 Max.   :27.20                            Max.   :18.000             
 Types.Colorectal.Race.Indigenous Types.Colorectal.Race.Hispanic
 Min.   : 0.000                   Min.   : 0.000                
 1st Qu.: 0.000                   1st Qu.: 5.900                
 Median : 0.000                   Median : 9.000                
 Mean   : 6.931                   Mean   : 8.233                
 3rd Qu.:13.950                   3rd Qu.:11.600                
 Max.   :34.700                   Max.   :18.000                
 Types.Lung.Total Types.Lung.Age and Sex.Female.18 - 44
 Min.   :15.60    Min.   :0.000                        
 1st Qu.:46.55    1st Qu.:0.850                        
 Median :52.40    Median :1.400                        
 Mean   :53.21    Mean   :1.259                        
 3rd Qu.:61.80    3rd Qu.:1.750                        
 Max.   :81.30    Max.   :2.900                        
 Types.Lung.Age and Sex.Male.18 - 44 Types.Lung.Age and Sex.Female.45 - 64
 Min.   :0.000                       Min.   :18.70                        
 1st Qu.:0.950                       1st Qu.:38.75                        
 Median :1.400                       Median :45.70                        
 Mean   :1.373                       Mean   :45.56                        
 3rd Qu.:1.800                       3rd Qu.:53.40                        
 Max.   :3.100                       Max.   :77.10                        
 Types.Lung.Age and Sex.Male.45 - 64 Types.Lung.Age and Sex.Female.> 64
 Min.   : 26.00                      Min.   : 92.7                     
 1st Qu.: 48.95                      1st Qu.:209.6                     
 Median : 59.70                      Median :225.8                     
 Mean   : 64.83                      Mean   :224.7                     
 3rd Qu.: 77.60                      3rd Qu.:248.2                     
 Max.   :112.60                      Max.   :298.3                     
 Types.Lung.Age and Sex.Male.> 64 Types.Lung.Race.White
 Min.   :153.2                    Min.   :20.40        
 1st Qu.:313.3                    1st Qu.:42.75        
 Median :342.6                    Median :48.10        
 Mean   :355.0                    Mean   :48.16        
 3rd Qu.:391.0                    3rd Qu.:54.50        
 Max.   :519.1                    Max.   :71.50        
 Types.Lung.Race.White non-Hispanic Types.Lung.Race.Black
 Min.   :20.60                      Min.   : 0.00        
 1st Qu.:43.70                      1st Qu.:38.15        
 Median :48.80                      Median :47.00        
 Mean   :49.34                      Mean   :44.06        
 3rd Qu.:54.95                      3rd Qu.:60.00        
 Max.   :71.90                      Max.   :73.20        
 Types.Lung.Race.Black non-Hispanic Types.Lung.Race.Asian
 Min.   : 0.00                      Min.   : 0.00        
 1st Qu.:39.95                      1st Qu.:18.35        
 Median :48.60                      Median :22.20        
 Mean   :44.50                      Mean   :19.32        
 3rd Qu.:60.35                      3rd Qu.:25.50        
 Max.   :73.60                      Max.   :33.90        
 Types.Lung.Race.Indigenous Types.Lung.Race.Hispanic
 Min.   : 0.00              Min.   : 0.00           
 1st Qu.: 4.45              1st Qu.:13.70           
 Median :20.90              Median :18.10           
 Mean   :27.31              Mean   :16.18           
 3rd Qu.:44.25              3rd Qu.:20.45           
 Max.   :87.50              Max.   :35.20           
glimpse(cancer)
Rows: 51
Columns: 75
$ State                                          <chr> "Alabama", "Alaska", "A…
$ Total.Rate                                     <dbl> 214.2, 128.1, 165.6, 22…
$ Total.Number                                   <dbl> 71529, 6361, 74286, 456…
$ Total.Population                               <dbl> 33387205, 4966180, 4484…
$ `Rates.Age.< 18`                               <dbl> 2.0, 1.7, 2.5, 2.3, 2.6…
$ `Rates.Age.18-45`                              <dbl> 18.5, 11.8, 13.6, 17.6,…
$ `Rates.Age.45-64`                              <dbl> 244.7, 170.9, 173.6, 25…
$ `Rates.Age.> 64`                               <dbl> 1017.8, 965.2, 840.2, 1…
$ `Rates.Age and Sex.Female.< 18`                <dbl> 2.0, 0.0, 2.6, 2.6, 2.4…
$ `Rates.Age and Sex.Male.< 18`                  <dbl> 2.1, 0.0, 2.5, 2.0, 2.8…
$ `Rates.Age and Sex.Female.18 - 45`             <dbl> 20.1, 13.9, 15.2, 19.5,…
$ `Rates.Age and Sex.Male.18 - 45`               <dbl> 16.8, 10.0, 12.2, 15.8,…
$ `Rates.Age and Sex.Female.45 - 64`             <dbl> 201.0, 157.6, 156.5, 21…
$ `Rates.Age and Sex.Male.45 - 64`               <dbl> 291.5, 183.0, 191.8, 29…
$ `Rates.Age and Sex.Female.> 64`                <dbl> 803.6, 849.6, 706.1, 83…
$ `Rates.Age and Sex.Male.> 64`                  <dbl> 1308.6, 1086.4, 1000.2,…
$ Rates.Race.White                               <dbl> 186.1, 168.2, 153.5, 19…
$ `Rates.Race.White non-Hispanic`                <dbl> 187.5, 170.2, 156.4, 19…
$ Rates.Race.Black                               <dbl> 216.1, 183.7, 166.8, 22…
$ Rates.Race.Asian                               <dbl> 81.3, 118.7, 93.0, 115.…
$ Rates.Race.Indigenous                          <dbl> 69.9, 247.2, 116.2, 59.…
$ `Rates.Race and Sex.Female.White`              <dbl> 149.2, 145.5, 130.8, 15…
$ `Rates.Race and Sex.Female.White non-Hispanic` <dbl> 150.2, 147.8, 134.0, 15…
$ `Rates.Race and Sex.Female.Black`              <dbl> 167.2, 141.6, 146.5, 18…
$ `Rates.Race and Sex.Female.Black non-Hispanic` <dbl> 167.9, 148.8, 154.3, 18…
$ `Rates.Race and Sex.Female.Asian`              <dbl> 84.9, 105.2, 80.6, 91.7…
$ `Rates.Race and Sex.Female.Indigenous`         <dbl> 53.8, 219.4, 100.5, 44.…
$ `Rates.Race and Sex.Male.White`                <dbl> 237.1, 195.6, 182.2, 24…
$ `Rates.Race and Sex.Male.White non-Hispanic`   <dbl> 239.2, 197.3, 184.7, 24…
$ `Rates.Race and Sex.Male.Black`                <dbl> 297.9, 240.8, 195.3, 30…
$ `Rates.Race and Sex.Male.Black non-Hispanic`   <dbl> 299.2, 246.6, 205.0, 30…
$ `Rates.Race and Sex.Male.Asian`                <dbl> 75.7, 142.8, 112.5, 157…
$ `Rates.Race and Sex.Male.Indigenous`           <dbl> 88.3, 284.9, 139.5, 74.…
$ Rates.Race.Hispanic                            <dbl> 66.5, 88.8, 128.5, 81.2…
$ `Rates.Race and Sex.Female.Hispanic`           <dbl> 58.3, 73.1, 106.5, 74.6…
$ `Rates.Race and Sex.Male.Hispanic`             <dbl> 77.1, 104.0, 158.4, 90.…
$ Types.Breast.Total                             <dbl> 27.4, 17.8, 23.3, 27.9,…
$ `Types.Breast.Age.18 - 44`                     <dbl> 5.1, 2.9, 3.8, 5.0, 4.0…
$ `Types.Breast.Age.45 - 64`                     <dbl> 39.8, 27.8, 33.2, 38.4,…
$ `Types.Breast.Age.> 64`                        <dbl> 95.7, 108.0, 90.5, 100.…
$ Types.Breast.Race.White                        <dbl> 20.5, 21.3, 20.4, 21.7,…
$ `Types.Breast.Race.White non-Hispanic`         <dbl> 20.6, 21.8, 20.9, 22.0,…
$ Types.Breast.Race.Black                        <dbl> 30.3, 0.0, 26.3, 31.1, …
$ `Types.Breast.Race.Black non-Hispanic`         <dbl> 30.4, 0.0, 28.0, 31.0, …
$ Types.Breast.Race.Asian                        <dbl> 0.0, 12.2, 10.7, 0.0, 1…
$ Types.Breast.Race.Indigenous                   <dbl> 0.0, 25.5, 11.4, 0.0, 7…
$ Types.Breast.Race.Hispanic                     <dbl> 0.0, 0.0, 16.2, 10.9, 1…
$ Types.Colorectal.Total                         <dbl> 19.4, 11.9, 14.9, 21.2,…
$ `Types.Colorectal.Age and Sex.Female.18 - 44`  <dbl> 1.6, 0.0, 1.3, 1.9, 1.2…
$ `Types.Colorectal.Age and Sex.Male.18 - 44`    <dbl> 2.3, 0.0, 1.4, 2.2, 1.4…
$ `Types.Colorectal.Age and Sex.Female.45 - 64`  <dbl> 18.0, 15.3, 12.6, 19.7,…
$ `Types.Colorectal.Age and Sex.Male.45 - 64`    <dbl> 28.7, 17.6, 19.2, 28.6,…
$ `Types.Colorectal.Age and Sex.Female.> 64`     <dbl> 78.4, 71.7, 67.6, 85.8,…
$ `Types.Colorectal.Age and Sex.Male.> 64`       <dbl> 106.0, 102.3, 85.2, 114…
$ Types.Colorectal.Race.White                    <dbl> 15.9, 13.6, 13.8, 17.7,…
$ `Types.Colorectal.Race.White non-Hispanic`     <dbl> 16.0, 13.8, 13.9, 17.9,…
$ Types.Colorectal.Race.Black                    <dbl> 24.4, 0.0, 18.7, 26.3, …
$ `Types.Colorectal.Race.Black non-Hispanic`     <dbl> 24.5, 0.0, 19.7, 26.4, …
$ Types.Colorectal.Race.Asian                    <dbl> 0.0, 12.5, 10.6, 0.0, 1…
$ Types.Colorectal.Race.Indigenous               <dbl> 0.0, 34.7, 10.1, 0.0, 7…
$ Types.Colorectal.Race.Hispanic                 <dbl> 5.7, 0.0, 13.1, 8.1, 11…
$ Types.Lung.Total                               <dbl> 66.4, 36.6, 42.3, 73.3,…
$ `Types.Lung.Age and Sex.Female.18 - 44`        <dbl> 1.7, 0.0, 1.1, 1.9, 0.8…
$ `Types.Lung.Age and Sex.Male.18 - 44`          <dbl> 2.4, 0.0, 0.8, 1.8, 0.8…
$ `Types.Lung.Age and Sex.Female.45 - 64`        <dbl> 54.8, 39.7, 33.2, 61.4,…
$ `Types.Lung.Age and Sex.Male.45 - 64`          <dbl> 102.9, 50.3, 47.0, 106.…
$ `Types.Lung.Age and Sex.Female.> 64`           <dbl> 221.7, 268.3, 191.9, 24…
$ `Types.Lung.Age and Sex.Male.> 64`             <dbl> 457.4, 335.0, 275.8, 48…
$ Types.Lung.Race.White                          <dbl> 59.9, 48.7, 39.5, 63.4,…
$ `Types.Lung.Race.White non-Hispanic`           <dbl> 60.4, 49.5, 42.2, 64.2,…
$ Types.Lung.Race.Black                          <dbl> 52.6, 45.6, 38.2, 62.9,…
$ `Types.Lung.Race.Black non-Hispanic`           <dbl> 52.8, 47.9, 40.4, 63.0,…
$ Types.Lung.Race.Asian                          <dbl> 23.0, 33.0, 21.3, 18.1,…
$ Types.Lung.Race.Indigenous                     <dbl> 22.9, 74.4, 11.1, 16.2,…
$ Types.Lung.Race.Hispanic                       <dbl> 14.8, 0.0, 21.6, 14.6, …
# Chunk 6: Check for missing values that possibly need to be cleaned.
colSums(is.na(cancer))
                                       State 
                                           0 
                                  Total.Rate 
                                           0 
                                Total.Number 
                                           0 
                            Total.Population 
                                           0 
                              Rates.Age.< 18 
                                           0 
                             Rates.Age.18-45 
                                           0 
                             Rates.Age.45-64 
                                           0 
                              Rates.Age.> 64 
                                           0 
               Rates.Age and Sex.Female.< 18 
                                           0 
                 Rates.Age and Sex.Male.< 18 
                                           0 
            Rates.Age and Sex.Female.18 - 45 
                                           0 
              Rates.Age and Sex.Male.18 - 45 
                                           0 
            Rates.Age and Sex.Female.45 - 64 
                                           0 
              Rates.Age and Sex.Male.45 - 64 
                                           0 
               Rates.Age and Sex.Female.> 64 
                                           0 
                 Rates.Age and Sex.Male.> 64 
                                           0 
                            Rates.Race.White 
                                           0 
               Rates.Race.White non-Hispanic 
                                           0 
                            Rates.Race.Black 
                                           0 
                            Rates.Race.Asian 
                                           0 
                       Rates.Race.Indigenous 
                                           0 
             Rates.Race and Sex.Female.White 
                                           0 
Rates.Race and Sex.Female.White non-Hispanic 
                                           0 
             Rates.Race and Sex.Female.Black 
                                           0 
Rates.Race and Sex.Female.Black non-Hispanic 
                                           0 
             Rates.Race and Sex.Female.Asian 
                                           0 
        Rates.Race and Sex.Female.Indigenous 
                                           0 
               Rates.Race and Sex.Male.White 
                                           0 
  Rates.Race and Sex.Male.White non-Hispanic 
                                           0 
               Rates.Race and Sex.Male.Black 
                                           0 
  Rates.Race and Sex.Male.Black non-Hispanic 
                                           0 
               Rates.Race and Sex.Male.Asian 
                                           0 
          Rates.Race and Sex.Male.Indigenous 
                                           0 
                         Rates.Race.Hispanic 
                                           0 
          Rates.Race and Sex.Female.Hispanic 
                                           0 
            Rates.Race and Sex.Male.Hispanic 
                                           0 
                          Types.Breast.Total 
                                           0 
                    Types.Breast.Age.18 - 44 
                                           0 
                    Types.Breast.Age.45 - 64 
                                           0 
                       Types.Breast.Age.> 64 
                                           0 
                     Types.Breast.Race.White 
                                           0 
        Types.Breast.Race.White non-Hispanic 
                                           0 
                     Types.Breast.Race.Black 
                                           0 
        Types.Breast.Race.Black non-Hispanic 
                                           0 
                     Types.Breast.Race.Asian 
                                           0 
                Types.Breast.Race.Indigenous 
                                           0 
                  Types.Breast.Race.Hispanic 
                                           0 
                      Types.Colorectal.Total 
                                           0 
 Types.Colorectal.Age and Sex.Female.18 - 44 
                                           0 
   Types.Colorectal.Age and Sex.Male.18 - 44 
                                           0 
 Types.Colorectal.Age and Sex.Female.45 - 64 
                                           0 
   Types.Colorectal.Age and Sex.Male.45 - 64 
                                           0 
    Types.Colorectal.Age and Sex.Female.> 64 
                                           0 
      Types.Colorectal.Age and Sex.Male.> 64 
                                           0 
                 Types.Colorectal.Race.White 
                                           0 
    Types.Colorectal.Race.White non-Hispanic 
                                           0 
                 Types.Colorectal.Race.Black 
                                           0 
    Types.Colorectal.Race.Black non-Hispanic 
                                           0 
                 Types.Colorectal.Race.Asian 
                                           0 
            Types.Colorectal.Race.Indigenous 
                                           0 
              Types.Colorectal.Race.Hispanic 
                                           0 
                            Types.Lung.Total 
                                           0 
       Types.Lung.Age and Sex.Female.18 - 44 
                                           0 
         Types.Lung.Age and Sex.Male.18 - 44 
                                           0 
       Types.Lung.Age and Sex.Female.45 - 64 
                                           0 
         Types.Lung.Age and Sex.Male.45 - 64 
                                           0 
          Types.Lung.Age and Sex.Female.> 64 
                                           0 
            Types.Lung.Age and Sex.Male.> 64 
                                           0 
                       Types.Lung.Race.White 
                                           0 
          Types.Lung.Race.White non-Hispanic 
                                           0 
                       Types.Lung.Race.Black 
                                           0 
          Types.Lung.Race.Black non-Hispanic 
                                           0 
                       Types.Lung.Race.Asian 
                                           0 
                  Types.Lung.Race.Indigenous 
                                           0 
                    Types.Lung.Race.Hispanic 
                                           0 
# Chunk 7: Create categories into three groups with the ntile() functoin. 
cancer <- cancer %>%mutate(
Death_Rate_Group = ntile(`Rates.Age.< 18`, 3))
# Chunk 8: Label the categories into low,medium, and high death rate groups. 
cancer <- cancer %>% mutate(Death_Rate_Group = factor(Death_Rate_Group,
labels = c("Low","Medium","High")))
# Chunk 9: Preview the cleaned data. I did it to check that the variable was correct.
head(cancer)
# A tibble: 6 × 76
  State      Total.Rate Total.Number Total.Population `Rates.Age.< 18`
  <chr>           <dbl>        <dbl>            <dbl>            <dbl>
1 Alabama          214.        71529         33387205              2  
2 Alaska           128.         6361          4966180              1.7
3 Arizona          166.        74286         44845598              2.5
4 Arkansas         224.        45627         20382448              2.3
5 California       151.       393980        261135696              2.6
6 Colorado         139         49035         35267734              1.9
# ℹ 71 more variables: `Rates.Age.18-45` <dbl>, `Rates.Age.45-64` <dbl>,
#   `Rates.Age.> 64` <dbl>, `Rates.Age and Sex.Female.< 18` <dbl>,
#   `Rates.Age and Sex.Male.< 18` <dbl>,
#   `Rates.Age and Sex.Female.18 - 45` <dbl>,
#   `Rates.Age and Sex.Male.18 - 45` <dbl>,
#   `Rates.Age and Sex.Female.45 - 64` <dbl>,
#   `Rates.Age and Sex.Male.45 - 64` <dbl>, …
# Chunk 10: Creates the graph that compares cancer rate in every state.
ggplot(cancer,aes(x = State,y = `Rates.Age.< 18`,

fill = Death_Rate_Group)) +
geom_col()

#Chunk 11: This adds colors to help make the graph more clear.
ggplot(cancer,
aes(x = State,y = `Rates.Age.< 18`,fill = Death_Rate_Group)) +
geom_col() +

  scale_fill_manual(values = c(
"Low"="#1b9e77",
"Medium"="#d95f02",
"High"="#7570b3"))

# Chunk 12: Add labels like the titles, axis labels, legend, and caption with the goal to describe the graph.
ggplot(cancer,
       aes(x = State,
           y = `Rates.Age.< 18`,
           fill = Death_Rate_Group)) +
  geom_col() +
  scale_fill_manual(values = c(
    "Low"="#1b9e77",
    "Medium"="#d95f02",
    "High"="#7570b3"
  )) +
  labs(
    title = "Childhood Cancer Death Rates Under Age 18 by State",
    x = "State",
    y = "Deaths per 100,000 Individuals Under Age 18",
    fill = "Death Rate Category",
    caption = "Source: CORGIS Cancer Mortality Dataset"
  )

# Chunk 13: Apply the theme and it cleans up the graph.
ggplot(cancer,
       aes(x = State,
           y = `Rates.Age.< 18`,
           fill = Death_Rate_Group)) +
  geom_col() +
  scale_fill_manual(values = c(
    "Low"="#1b9e77",
    "Medium"="#d95f02",
    "High"="#7570b3"
  )) +
  labs(
    title = "Childhood Cancer Death Rates Under Age 18 by State",
    x = "State",
    y = "Deaths per 100,000 Individuals Under Age 18",
    fill = "Death Rate Category",
    caption = "Source: CORGIS Cancer Mortality Dataset"
  ) +
  theme_minimal() +
  theme(
    axis.text.x = element_text(angle = 90, hjust = 1)
  )

# Chunk 14: Selects the variables breast, colorectal, and lung cancer.
cancer_type_data <- cancer %>%
select(

  Breast = Types.Breast.Total,
Colorectal = Types.Colorectal.Total,
Lung = Types.Lung.Total)
# Chunk 15: Convert to long format so it is more easy to use in ggplot2
cancer_long <- cancer_type_data %>%pivot_longer(everything(),names_to = "Cancer_Type",
values_to = "Death_Rate")
# Chunk 16: Calculate averages of the death rates for each cancer type.
average_rates <- cancer_long %>%group_by(Cancer_Type) %>%summarize(
Average_Rate = mean(Death_Rate, na.rm = TRUE))
# Chunk 17: Create the graph that shows the average death rate for breast,colorectal, and lung cancer.
ggplot(average_rates,aes(x = Cancer_Type,y = Average_Rate,fill = Cancer_Type)) +
geom_col()

# Chunk 18: Add colors so it is easier to see each cancer type.
ggplot(average_rates,
aes(x = Cancer_Type,
y = Average_Rate,
fill = Cancer_Type)) +
geom_col() +

  scale_fill_manual(values = c("Breast"="#e7298a","Colorectal"="#66a61e","Lung"="#7570b3"))

# Chunk 19: Create the base graph and it puts variables on the x and y axis and fills it in with color.
ggplot(average_rates,aes(x = Cancer_Type,y = Average_Rate,fill = Cancer_Type))

# Chunk 20: Adds bars to represent death rate for each type of cancer.
ggplot(average_rates,aes(x = Cancer_Type,y = Average_Rate,fill = Cancer_Type)) +
geom_col()

# Chunk 21: Adds custom colors to easily see each cancer type.

ggplot(average_rates,
aes(x = Cancer_Type,
y = Average_Rate,
fill = Cancer_Type)) +
geom_col() +

  scale_fill_manual(values = c(
"Breast" = "#e7298a",
"Colorectal" = "#66a61e",
"Lung" = "#7570b3" ))

# Chunk 22: Adds the titles and descriptions of what is going on in the graph.
ggplot(average_rates,
aes(x = Cancer_Type,
y = Average_Rate,

fill = Cancer_Type)) +
geom_col() +
scale_fill_manual(values = c(
"Breast" = "#e7298a",
"Colorectal" = "#66a61e",
"Lung" = "#7570b3"
)) +

  labs(
title = "Average Cancer Death Rate by Cancer Type")

# Chunk 23: Add axis labels
ggplot(average_rates,
aes(x = Cancer_Type,
y = Average_Rate,
fill = Cancer_Type)) +
geom_col() +

  scale_fill_manual(values = c(
"Breast" = "#e7298a",
"Colorectal" = "#66a61e",
"Lung" = "#7570b3")) +

  labs(
title = "Average Cancer Death Rate by Cancer Type",
x = "Cancer Type",
y = "Average Death Rate per 100,000 People")

# Chunk 25: Add the caption and gives the source of the data.
ggplot(average_rates,
aes(x = Cancer_Type,y = Average_Rate,fill = Cancer_Type)) +
geom_col() +

  scale_fill_manual(values = c(
"Breast" = "#e7298a",
"Colorectal" = "#66a61e",
"Lung" = "#7570b3")) +

  labs(title = "Average Cancer Death Rate by Cancer Type",
x = "Cancer Type",
y = "Average Death Rate per 100,000 People",
fill = "Cancer Type",
caption = "Source: CORGIS Cancer Mortality Dataset")

# Chunk 26: Apply the theme to make the graph look more put together.
average_rates <- cancer_long %>%
  group_by(Cancer_Type) %>%
  summarize(
    Average_Rate = mean(Death_Rate, na.rm = TRUE),
    .groups = "drop"
  )
ggplot(average_rates,aes(x = Cancer_Type,y = Average_Rate,fill = Cancer_Type)) +
geom_col() +
scale_fill_manual(values = c(
"Breast" = "#e7298a",
"Colorectal" = "#66a61e",
"Lung" = "#7570b3"
  )) +
  labs(
    title = "Average Cancer Death Rate by Cancer Type",
    x = "Cancer Type",
    y = "Average Death Rate per 100,000 People",
    fill = "Cancer Type",
    caption = "Source: CORGIS Cancer Mortality Dataset"
  ) +
  theme_minimal()