map_results: Map flattened NBA API data to statsnbaR data

Description Usage Arguments Details Value See Also

Description

This takes the data.frames returned by flatten_json_rowSet and converts the attributes (columns) to the desired data types specified by statsnbaR's internal YAML.

Usage

1
map_results(df, api.mapping)

Arguments

df

Flattened NBA API data

api.mapping

The mapping from API data to statsnbaR data

Details

The column name is used to identify the correct mapping and/or type conversion function. The mappings and data types are specified in the statsnbaR internal YAML data, available at https://www.github.com/stephematician/statsnbaR/tree/master/data-raw/ADL.yaml

The YAML specification of the data type might look as follows:

1
2
3
4
5
6
7
data    :
    played :
        class   : logical
        mapping : {
            'Y' : TRUE,    # played
            'N' : FALSE    # never played
            }

Now any column named ‘played’ would be mapped from the character values to a logical TRUE or FALSE, and converted to the logical class (a redundant step for this example).

Value

The data frame with mapped values

See Also

type_converters map_result_values


stephematician/statsnbaR documentation built on May 30, 2019, 3:17 p.m.