head(er_visits_age)
## # A tibble: 6 × 7
## YEAR GENDER AGE RATE L95CL U95CL VISITS
## <dbl> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 2011 Both genders 0-4 years old 3.52 1.82 6.16 12
## 2 2011 Both genders 15-34 years old 7.34 5.95 8.74 106
## 3 2011 Both genders 35-64 years old 5.84 4.80 6.88 121
## 4 2011 Both genders 5-14 years old 5.20 3.50 6.90 36
## 5 2011 Both genders 65+ years old 8.34 5.98 10.7 48
## 6 2011 Both genders All ages 6.30 5.62 6.99 323
Notice that AGE
is a chr
variable. This indicates that the values are character strings.
R does not realize that there is any order related to the AGE
values. It will assume that it is alphabetical (for numbers, this means ascending order).
However, we know that the order is: 0-4 years old, 5-14 years old, 15-34 years old, 35-64 years old, 65+ years old, and All ages.