Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Questions About Lab #6 #11

Open
Niagara1000 opened this issue Apr 22, 2020 · 1 comment
Open

Questions About Lab #6 #11

Niagara1000 opened this issue Apr 22, 2020 · 1 comment

Comments

@Niagara1000
Copy link

Hi,

I am confused about what this part of the code means:

Under part 1 Regression Model -> Grab Census Data, we have this code:

census <-map_dfr(
  years,
  ~ get_acs(
geography = "county",
variables = c(
              HousePrice = 'B25077_001', #Median Value of  Housing Units
              total_pop ='B01001_001',
              pop_white = 'B01001H_001',  # not hispanic
              pop_black = 'B01001B_001',
              pop_hispanic = 'B01001I_001',
              below_poverty = 'B05010_002',
              speak_english = 'B06007_002',
              speak_spanish = 'B06007_003',
              bachelors = 'B06008_002',
              married = 'B06008_003',
              no_hs = 'B06009_002',
              hs = 'B06009_003',
              bach_degree = 'B06009_005',
              grad_degree = 'B06009_006'),
year = .x  
),
  .id = "year"
)

what does the .x and .id refer to?

@AntJam-Howell
Copy link
Collaborator

AntJam-Howell commented Apr 22, 2020

@Niagara1000 'years' is the list we created that contains two elements, 2007 and 2012. years in our case is the .x that is required as an input field for the map_dfr function (link). year is part of the get_acs function and instead of directly saying year 2007, we enter in .x, which calls the 'years' list containing our two values, 2007 and 2012. get_acs makes the call on the 2007 data, then makes the call again on the 2012 data, and then combines that output into a data frame. .id=year is the variable name assigned to the 2007 and 2012 years. You can change .id="year" to .id="Test" and look at the data output and you will see the variable name is changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants