stephenholzman / tidyusafec

An R wrapper for the OpenFEC API that features tidy cleaning.
https://stephenholzman.github.io/tidyusafec/
Other
7 stars 0 forks source link

Committee remains nested when calling get_itemized_contributions() #28

Open ChrisCioffi opened 4 years ago

ChrisCioffi commented 4 years ago

Hi when I run this:

select all candidates running for Senate, unnest the data, deliver it in a df, and make sure they raised money

SD_senate <- search_candidates(state = "SD", election_year = "2020", office = "S", candidate_status = "C" , has_raised_funds = TRUE, unnest_committees = TRUE ) %>%

get all their itemized contributions

get_itemized_contributions(data_structure = "tidy")

The candidate_name/committee_name/ columns render NAs, and there is no party column. But the committee column contains a nested list with this and other information.

Any way to resolve this?

stephenholzman commented 4 years ago

Investigating. The API looks to now be returning null values for candidate_name, committee_name, etc where there were previously appropriate values.

Example raw query: https://api.open.fec.gov/v1/schedules/schedule_a/?committee_id=C00638973&api_key=DEMO_KEY&per_page=100

stephenholzman commented 4 years ago

I don't think I want to overwrite the NULL values the FEC is providing right now. I'll shoot a question to the mailing list to get a full explanation for why most of those values are NULL (upon further investigation, some do return candidate names and I was wrong in my initial assessment about previous API behavior).

For now to be safe, I would only send one committee into get_itemized_contributions. Example:

`#select all candidates running for Senate, unnest the data, deliver it in a df, and make sure they raised money

SD_senate_BORGLUM <- search_candidates(state = "SD", election_year = "2020", office = "S", candidate_status = "C" , has_raised_funds = TRUE, unnest_committees = TRUE ) %>%

get all their itemized contributions for BORGLUM

filter(str_detect(name, "BORGLUM")) %>%

get_itemized_contributions(data_structure = "tidy") %>%

make sure to include each contribution only once, the results without the below line allow for tracking a contribution through various committees.

filter(is_individual == TRUE, is.na(memo_code))`