See if you want to get the states with two or more "a"s in them, then in that case use :
grep('.*a.*a.*', state.name, value = TRUE, ignore.case = TRUE)
The output in R programming will be:
# [1] "Alabama" "Alaska" "Arizona" "Arkansas"
# [5] "California" "Delaware" "Hawaii" "Indiana"
# [9] "Kansas" "Louisiana" "Maryland" "Massachusetts"
#[13] "Montana" "Nebraska" "Nevada" "North Carolina"
#[17] "North Dakota" "Oklahoma" "Pennsylvania" "South Carolina"
#[21] "South Dakota"
And let say, you want exactly two "a"s, what you can do is use the str_count to count the number of "a"s and then perform the subsetting.
state.name[stringr::str_count(state.name, 'a|A') == 2]
# [1] "Arizona" "California" "Delaware" "Hawaii"
# [5] "Indiana" "Kansas" "Louisiana" "Maryland"
# [9] "Massachusetts" "Montana" "Nebraska" "Nevada"
#[13] "North Carolina" "North Dakota" "Oklahoma" "Pennsylvania"
#[17] "South Carolina" "South Dakota"