library(readr)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(tibble)
jy_csv <- read.csv("C:/Users/Jessica/Desktop/712/health_data.csv")
head(jy_csv)
tail (jy_csv)
glimpse(jy_csv)
## Observations: 5
## Variables: 12
## $ Geo_FIPS <int> 36001, 36031, 36061, 36063, 36069
## $ Geo_NAME <fct> Albany County, Essex County, New York County, Niag...
## $ Geo_QNAME <fct> "Albany County, New York ", "Essex County, New Yor...
## $ Geo_STATE <int> 36, 36, 36, 36, 36
## $ Geo_COUNTY <int> 1, 31, 61, 63, 69
## $ SE_T011_001 <dbl> 13.6, 14.3, 13.2, 15.8, 13.9
## $ SE_T011_002 <dbl> 18.7, 18.7, 21.3, 18.5, 19.6
## $ SE_T012_001 <dbl> 4.955115, 1.995570, 0.000000, 5.272294, 2.899159
## $ SE_T012_002 <dbl> 85.59618, 100.00000, 98.43317, 87.75806, 83.03731
## $ SE_T012_003 <dbl> 27.2, 28.5, 14.7, 30.2, 29.5
## $ SE_T012_004 <dbl> 22.0, 27.3, 17.6, 21.8, 17.4
## $ SE_T012_005 <dbl> 30.51945, 33.00669, 60.32939, 35.05148, 25.14412
names(jy_csv)
## [1] "Geo_FIPS" "Geo_NAME" "Geo_QNAME" "Geo_STATE" "Geo_COUNTY"
## [6] "SE_T011_001" "SE_T011_002" "SE_T012_001" "SE_T012_002" "SE_T012_003"
## [11] "SE_T012_004" "SE_T012_005"
health <- rename(jy_csv,
county_name = Geo_NAME,
current_smokers = SE_T011_001,
drinking_adult = SE_T011_002,
limited_access_to_healthyfoods = SE_T012_001,
access_to_exercise_opportunities = SE_T012_002,
obese_person_twenty_andover = SE_T012_003,
physically_inacive_person_twentyandup = SE_T012_004,
children_elligible_for_free_lunch_eighteenorless = SE_T012_005)
health <- select(health,
county_name,
current_smokers,
drinking_adult,
limited_access_to_healthyfoods,
access_to_exercise_opportunities,
obese_person_twenty_andover,
physically_inacive_person_twentyandup,
children_elligible_for_free_lunch_eighteenorless)
head(health)
tail (health)
glimpse(health)
## Observations: 5
## Variables: 8
## $ county_name <fct> Albany County...
## $ current_smokers <dbl> 13.6, 14.3, 1...
## $ drinking_adult <dbl> 18.7, 18.7, 2...
## $ limited_access_to_healthyfoods <dbl> 4.955115, 1.9...
## $ access_to_exercise_opportunities <dbl> 85.59618, 100...
## $ obese_person_twenty_andover <dbl> 27.2, 28.5, 1...
## $ physically_inacive_person_twentyandup <dbl> 22.0, 27.3, 1...
## $ children_elligible_for_free_lunch_eighteenorless <dbl> 30.51945, 33....
names(health)
## [1] "county_name"
## [2] "current_smokers"
## [3] "drinking_adult"
## [4] "limited_access_to_healthyfoods"
## [5] "access_to_exercise_opportunities"
## [6] "obese_person_twenty_andover"
## [7] "physically_inacive_person_twentyandup"
## [8] "children_elligible_for_free_lunch_eighteenorless"
avgsmoke <- summarize(health, smoker = mean(current_smokers))
avgdrinker <- summarize(health,drinker = mean(drinking_adult))
avgsmoke
avgdrinker