Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

pp_convert_to_data_frame

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

tmp <- get_candidates_in_race('MI','house',11)
pp_convert_to_data_frame(tmp)
pp_convert_to_data_frame(tmp,'summary')

ProPublicaR

Access Functions for ProPublica's APIs

v1.1.1
GPL-3 | file LICENSE
Authors
Aleksander Dietrichson [aut, cre], Joselina Davit [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.