There are two packages, tidycensus and acs that provide access to the US Census decennials and the annual estimates. acs will tell you how to get an Census API key and some guidance in forming queries.
With tidycensus, it's going to look like
# obtain 50-state ACS 2017 population estimates with geographic data
states_pop <- get_estimates("state", product = "population", geometry = TRUE, shift_geo = TRUE) %>% filter(variable == "POP") %>% filter(GEOID != 11) %>% mutate(geoid = as.integer(GEOID)) %>% select(GEOID, NAME, geoid, value) %>% mutate(POP_TOT = value) %>% select(-value)
# obtain 50_state ACS 2017 population estimates for white, non-Hispanic
# requires manual selection on ASC site to limit estimate to that ethnicity
states_ethnic <- get_acs(geography = "state", variables = "B01001H_001") %>% filter(GEOID != 11 & GEOID != 72) %>% select(GEOID, NAME, estimate) %>% mutate(WHITE = estimate) %>% select(-estimate)