pp_convert_to_data_frame: Convert a ProPublica API result a Data Frame

View source: R/pp_convert_to_data_frame.R

pp_convert_to_data_frameR Documentation

Convert a ProPublica API result a Data Frame

Description

The function attempts to convert the result of a ProPublica API call to a data.frame. If the result of the API call contains various parts, the which_part parameter can be used to specify for which of these the conversion is required. Typically the 'payload' resides in the 'results' field, which is the default, but occasionally the summary and meta fields might be of interest.

Usage

pp_convert_to_data_frame(what, which_part = c("result", "summary", "meta"))

Arguments

what

Return value from one of the get_ functions.

which_part

Which part are we converting. Defaults to 'results', but 'summary' and 'meta' may be useful in some cases.

Details

The function also replaces . (dot) with _ (underscore) in column names for compatibility with database inserts (e.g. DBI::dbWriteTable)

Value

a data.frame

Examples

## Not run: 
tmp <- get_candidates_in_race('MI','house',11)
pp_convert_to_data_frame(tmp)
pp_convert_to_data_frame(tmp,'summary')


## End(Not run)

ProPublicaR documentation built on Sept. 8, 2023, 5:53 p.m.