Skip to contents

Get policy actions and stringency data from JSON

Usage

get_data(json)

Arguments

json

A JSON string, URL or file created using get_json_time() or get_json_actions().

Value

A tibble of time series stringency index data if json is a time series endpoint or a named list of two tibbles (the first tibble is named policyActions and the second tibble is named stringencyData) if json is a policy actions endpoint.

Examples

## Get time series JSON endpoint
x <- get_json_time(from = "2020-10-29", to = "2020-10-31")

## Get time series stringency index data
get_data(x)
#> # A tibble: 552 × 8
#>    date_value country_code confirmed deaths stringency_actual stringency
#>    <date>     <chr>            <int>  <int>             <dbl>      <dbl>
#>  1 2020-10-29 ABW               4472     37             47.2       47.2 
#>  2 2020-10-29 AFG              41145   1529              9.26       9.26
#>  3 2020-10-29 AGO              10269    275             65.7       65.7 
#>  4 2020-10-29 ALB              20315    499             54.6       54.6 
#>  5 2020-10-29 AND               4567     73             55.6       55.6 
#>  6 2020-10-29 ARE             130336    488             54.6       54.6 
#>  7 2020-10-29 ARG            1143800  30442             81.9       81.9 
#>  8 2020-10-29 AUS              27579    907             60.6       60.6 
#>  9 2020-10-29 AUT              91951   1353             64.8       64.8 
#> 10 2020-10-29 AZE              53152    708             64.4       64.4 
#> # ℹ 542 more rows
#> # ℹ 2 more variables: stringency_legacy <dbl>, stringency_legacy_disp <dbl>

## Get policy actions JSON endpoint
x <- get_json_actions(ccode = "AFG", from = NULL, to = "2020-07-16")

## Get data on policy actions and stringency index
get_data(x)
#> $policyActions
#> # A tibble: 23 × 9
#>    policy_type_code policy_type_display   policyvalue policyvalue_actual flagged
#>    <chr>            <chr>                       <int>              <int> <lgl>  
#>  1 C1               School closing                  3                  3 TRUE   
#>  2 C2               Workplace closing               3                  3 FALSE  
#>  3 C3               Cancel public events            2                  2 TRUE   
#>  4 C4               Restrictions on gath…           4                  4 TRUE   
#>  5 C5               Close public transpo…           2                  2 FALSE  
#>  6 C6               Stay at home require…           2                  2 FALSE  
#>  7 C7               Restrictions on inte…           2                  2 FALSE  
#>  8 C8               International travel…           1                  1 NA     
#>  9 E1               Income support                  0                  0 NA     
#> 10 E2               Debt/contract relief            0                  0 NA     
#> # ℹ 13 more rows
#> # ℹ 4 more variables: is_general <lgl>, notes <chr>,
#> #   flag_value_display_field <chr>, policy_value_display_field <chr>
#> 
#> $stringencyData
#> # A tibble: 1 × 6
#>   date_value country_code confirmed deaths stringency_actual stringency
#>   <chr>      <chr>            <int>  <int>             <dbl>      <dbl>
#> 1 2020-07-16 AFG              35156   1117              78.7       78.7
#>