General framework for loading and tidying data.

LoadData(
  functionNames = NULL,
  custom = FALSE,
  filepath = NULL,
  interactiveMode = interactive(),
  tidy = TRUE,
  DaysOld = 30,
  minimumpercapitaactivecases = 0,
  RiskEval = NULL,
  dropNACountry = TRUE,
  dropNAall = FALSE,
  verbose = TRUE
)

Arguments

functionNames

Name(s) of function representing that for loading data - options are in countrylist. Use NULL to attempt to download all available datasets.

custom

If TRUE, allows for use with functions not listed in object countrylist (experimental usage).

filepath

Optionally, provide a filepath to save an error csv file to.

interactiveMode

Set whether the session is being run interactively. If not and no googledrive oauth token is found, avoid data requiring googledrive auth token.

tidy

If TRUE, then perform tidying according to other parameters. If FALSE, then do nothing. (passed to tidy_Data).

DaysOld

Set any pInf data more than this days old to NA.(passed to tidy_Data).

minimumpercapitaactivecases

Set any pInf data less than this to NA.(passed to tidy_Data).

RiskEval

Set pInf to NA when risk is below RiskEval$minimumRisk (%) using RiskEval$ascertainmentbias and a maximum group size, RiskEval$maximumN (Note: this setting overwrites minimumpercapitaactivecases). (passed to tidy_Data).

dropNACountry

If TRUE, remove rows for countries whose pInf estimates all return NA.(passed to tidy_Data).

dropNAall

If TRUE, remove rows for any region whose pInf estimates all return NA. (passed to tidy_Data).

verbose

If TRUE, reports on loading progress and returns warnings/errors to console.

Value

A simple feature returning the date of most recent data (DateReport), a unique region code (geoid), the region name (RegionName) and country name (Country), the number of active cases per capita (pInf) and the regions geometry (geometry).

See also

Examples

LoadData("LoadUS")
#> LoadUS 
#> Simple feature collection with 3216 features and 5 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -178.8706 ymin: 17.91523 xmax: 179.7739 ymax: 71.29585
#> Geodetic CRS:  WGS 84
#> # A tibble: 3,216 × 6
#>    DateReport geoid          RegionN…¹ Country    pInf                  geometry
#>  * <chr>      <chr>          <chr>     <chr>     <dbl>        <MULTIPOLYGON [°]>
#>  1 2023-01-22 USA840_AL_1001 Autauga,… United… 0.00235 (((-86.90674 32.53698, -…
#>  2 2023-01-22 USA840_AL_1003 Baldwin,… United… 0.00186 (((-87.92538 30.64889, -…
#>  3 2023-01-22 USA840_AL_1005 Barbour,… United… 0.00399 (((-85.66363 31.78236, -…
#>  4 2023-01-22 USA840_AL_1007 Bibb, Al… United… 0.00258 (((-87.4212 32.87451, -8…
#>  5 2023-01-22 USA840_AL_1009 Blount, … United… 0.00220 (((-86.95366 33.8153, -8…
#>  6 2023-01-22 USA840_AL_1011 Bullock,… United… 0.00212 (((-85.99916 32.25054, -…
#>  7 2023-01-22 USA840_AL_1013 Butler, … United… 0.00250 (((-86.90894 31.96167, -…
#>  8 2023-01-22 USA840_AL_1015 Calhoun,… United… 0.00302 (((-86.04399 33.7636, -8…
#>  9 2023-01-22 USA840_AL_1017 Chambers… United… 0.00303 (((-85.59315 32.72853, -…
#> 10 2023-01-22 USA840_AL_1019 Cherokee… United… 0.00248 (((-85.57679 34.48444, -…
#> # … with 3,206 more rows, and abbreviated variable name ¹​RegionName
LoadData("LoadUS", dropNAall = TRUE)
#> LoadUS 
#> Simple feature collection with 3150 features and 5 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -178.8706 ymin: 17.91523 xmax: 179.7739 ymax: 71.29585
#> Geodetic CRS:  WGS 84
#> # A tibble: 3,150 × 6
#>    DateReport geoid          RegionN…¹ Country    pInf                  geometry
#>    <chr>      <chr>          <chr>     <chr>     <dbl>        <MULTIPOLYGON [°]>
#>  1 2023-01-22 USA840_AL_1001 Autauga,… United… 0.00235 (((-86.90674 32.53698, -…
#>  2 2023-01-22 USA840_AL_1003 Baldwin,… United… 0.00186 (((-87.92538 30.64889, -…
#>  3 2023-01-22 USA840_AL_1005 Barbour,… United… 0.00399 (((-85.66363 31.78236, -…
#>  4 2023-01-22 USA840_AL_1007 Bibb, Al… United… 0.00258 (((-87.4212 32.87451, -8…
#>  5 2023-01-22 USA840_AL_1009 Blount, … United… 0.00220 (((-86.95366 33.8153, -8…
#>  6 2023-01-22 USA840_AL_1011 Bullock,… United… 0.00212 (((-85.99916 32.25054, -…
#>  7 2023-01-22 USA840_AL_1013 Butler, … United… 0.00250 (((-86.90894 31.96167, -…
#>  8 2023-01-22 USA840_AL_1015 Calhoun,… United… 0.00302 (((-86.04399 33.7636, -8…
#>  9 2023-01-22 USA840_AL_1017 Chambers… United… 0.00303 (((-85.59315 32.72853, -…
#> 10 2023-01-22 USA840_AL_1019 Cherokee… United… 0.00248 (((-85.57679 34.48444, -…
#> # … with 3,140 more rows, and abbreviated variable name ¹​RegionName
LoadData("LoadNewZealand",tidy = FALSE)
#> LoadNewZealand 
#> Simple feature collection with 20 features and 5 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 166.4263 ymin: -47.28706 xmax: 178.5504 ymax: -34.41452
#> Geodetic CRS:  WGS 84
#> First 10 features:
#>    DateReport        geoid                    RegionName     Country
#> 1  2022-02-11 NZL554_00_01        Northland, New Zealand New Zealand
#> 2  2022-02-11 NZL554_00_02        Waitemata, New Zealand New Zealand
#> 3  2022-02-11 NZL554_00_03         Auckland, New Zealand New Zealand
#> 4  2022-02-11 NZL554_00_04 Counties Manukau, New Zealand New Zealand
#> 5  2022-02-11 NZL554_00_05          Waikato, New Zealand New Zealand
#> 6  2022-02-11 NZL554_00_06            Lakes, New Zealand New Zealand
#> 7  2022-02-11 NZL554_00_07    Bay of Plenty, New Zealand New Zealand
#> 8  2022-02-09 NZL554_00_08       Tairāwhiti, New Zealand New Zealand
#> 9  2022-02-11 NZL554_00_09         Taranaki, New Zealand New Zealand
#> 10 2022-02-11 NZL554_00_10      Hawke's Bay, New Zealand New Zealand
#>            pInf                       geometry
#> 1  0.0006516145 MULTIPOLYGON (((174.5898 -3...
#> 2  0.0003427975 MULTIPOLYGON (((174.6544 -3...
#> 3  0.0009744380 MULTIPOLYGON (((174.8526 -3...
#> 4  0.0019931647 MULTIPOLYGON (((175.2833 -3...
#> 5  0.0008287895 MULTIPOLYGON (((175.8982 -3...
#> 6  0.0006621188 MULTIPOLYGON (((176.6242 -3...
#> 7  0.0005054653 MULTIPOLYGON (((178.0066 -3...
#> 8  0.0002821503 MULTIPOLYGON (((177.9118 -3...
#> 9  0.0000917319 MULTIPOLYGON (((174.5904 -3...
#> 10 0.0001921062 MULTIPOLYGON (((177.799 -38...
LoadData(c("LoadUS","LoadMalaysia"))
#> LoadUS 
#> LoadMalaysia 
#> Simple feature collection with 3232 features and 5 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -178.8706 ymin: 0.8623942 xmax: 179.7739 ymax: 71.29585
#> Geodetic CRS:  WGS 84
#> # A tibble: 3,232 × 6
#>    DateReport geoid          RegionN…¹ Country    pInf                  geometry
#>  * <chr>      <chr>          <chr>     <chr>     <dbl>        <MULTIPOLYGON [°]>
#>  1 2023-01-22 USA840_AL_1001 Autauga,… United… 0.00235 (((-86.90674 32.53698, -…
#>  2 2023-01-22 USA840_AL_1003 Baldwin,… United… 0.00186 (((-87.92538 30.64889, -…
#>  3 2023-01-22 USA840_AL_1005 Barbour,… United… 0.00399 (((-85.66363 31.78236, -…
#>  4 2023-01-22 USA840_AL_1007 Bibb, Al… United… 0.00258 (((-87.4212 32.87451, -8…
#>  5 2023-01-22 USA840_AL_1009 Blount, … United… 0.00220 (((-86.95366 33.8153, -8…
#>  6 2023-01-22 USA840_AL_1011 Bullock,… United… 0.00212 (((-85.99916 32.25054, -…
#>  7 2023-01-22 USA840_AL_1013 Butler, … United… 0.00250 (((-86.90894 31.96167, -…
#>  8 2023-01-22 USA840_AL_1015 Calhoun,… United… 0.00302 (((-86.04399 33.7636, -8…
#>  9 2023-01-22 USA840_AL_1017 Chambers… United… 0.00303 (((-85.59315 32.72853, -…
#> 10 2023-01-22 USA840_AL_1019 Cherokee… United… 0.00248 (((-85.57679 34.48444, -…
#> # … with 3,222 more rows, and abbreviated variable name ¹​RegionName
if (FALSE) {
LoadData()
}