Learn R Programming

⚠️There's a newer version (1.0.2) of this package.Take me there.

zoltr - An R client for the Zoltar data repository API

Overview

This package contains functions for working with the Zoltar forecast repository's API, including projects, models, forecasts, and scores. Read more about this package at the zoltr pkgdown site. Documentation on Zolar itself is at docs.zoltardata.com.

Installation

You can install the released version of zoltr from CRAN with:

install.packages("zoltr")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("reichlab/zoltr")

Usage

Read more at the zoltr pkgdown site, but briefly you use the new_connection() function to create a connection to Zoltar and then pass that connection along with the URL of the resource of interest (e.g., a project, model, or forecast) to this package's various functions like projects(), project_info(), or scores().

library(zoltr)
zoltar_connection <- new_connection()
zoltar_authenticate(zoltar_connection, Sys.getenv("Z_USERNAME"), Sys.getenv("Z_PASSWORD"))
zoltar_connection
#> ZoltarConnection 'https://zoltardata.com' authenticated (exp=2020-04-09 18:00:13 UTC)

the_projects <- projects(zoltar_connection)
project_url <- the_projects[the_projects$name == "Docs Example Project", "url"]
the_project_info <- project_info(zoltar_connection, project_url)
names(the_project_info)
#>  [1] "id"                    "url"                   "owner"                
#>  [4] "is_public"             "name"                  "description"          
#>  [7] "home_url"              "logo_url"              "core_data"            
#> [10] "time_interval_type"    "visualization_y_label" "truth"                
#> [13] "model_owners"          "score_data"            "models"               
#> [16] "units"                 "targets"               "timezeros"
the_project_info$name
#> [1] "Docs Example Project"

Forecast data format

The native forecast data format supported by the Zoltar API is a list. See docs.zoltardata.com for format details. You can find an example at vignettes/docs-predictions.json . By convention this package referred to this as forecast_data. This package supports conversion to this format (which is used throughout the package) from the CDC's CSV file format [1] via the forecast_data_from_cdc_csv_file() function. Future versions will support bidirectional conversion, as well as support for a more general CSV format.

[1] Details about the CDC CSV format can be found at flu_challenge_2016-17_update.docx.

Copy Link

Version

Install

install.packages('zoltr')

Monthly Downloads

318

Version

0.5.1

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Matthew Cornell

Last Published

April 15th, 2020

Functions in zoltr (0.5.1)

models

Get a project's models
timezero_info

Get information about a timezero
timezeros

Get a project's timezeros
new_connection

Get a connection to a Zoltar host
target_info

Get information about a target
project_info

Get information about a project
zoltr-package

zoltr: Interface to the 'Zoltar' Forecast Repository API
zoltar_units

Get a project's zoltar_units
targets

Get a project's targets
upload_info_forecast_url

Get a new forecast upload's url
projects

Get information about all projects
scores

Get a project's scores
%>%

Pipe operator
forecast_data_from_cdc_data_frame

`forecast_data_from_cdc_csv_file()`helper
zoltar_authenticate

Log in to a Zoltar host
upload_info

Get an upload's information
upload_forecast

Upload a forecast
truth

Get a project's truth
model_info

Get information about a model
get_resource

Get JSON for a resource (URL). Authenticates if necessary
unit_info

Get information about a unit
forecasts

Get a model's forecasts
delete_forecast

Delete a forecast
create_model

Create a model
forecast_info

Gets a forecast's information
delete_model

Delete a model
create_project

Create a project
forecast_data_from_cdc_csv_file

Loads and converts a CDC CSV file to Zoltar's native `list` format
delete_project

Delete a project
download_forecast

Gets a forecast's data