Skip to contents

Convert json output of ejscreenRESTbroker() to a simple 1-row data.frame

Usage

ejscreenRESTbroker2table(brokeroutput, getstatefromplacename = TRUE)

Arguments

brokeroutput

the results of ejscreenRESTbroker()

getstatefromplacename

set to FALSE if you need the exact output of API and TRUE if you want to try to extract ST abbrev and statename from the placename field, which is more likely to be correct than the stateAbbr and stateName fields in the API output.

Value

a data.frame of 1 row (a site) and many columns (indicators)

Details

This function assumes we got the full results via the API using ejscreenRESTbroker().

It handles all 300 or so indicators, including those categorized by API outputs as main, extras, and residential populations, with duplicated indicators removed.

It drops redundant columns where the same numbers had been returned from API using the normal name and a synonym name, as with "TOTALPOP" and "totalPop"

ejscreenapi1() relies on this function and essentially does this:

ejscreenRESTbroker2table(ejscreenRESTbroker())

Drops the percent signs and makes those values numeric, converting text like 45% to the number 45.

To ensure there is one result per input point, even if some points are invalid, for later steps like ejscreenapi1, ejscreenapi, ejscreenapi_plus, ejscreenit(), this function will return a row with the right columns but all NA values if the input seems wrong.