Join us for
RADAR: AI Edition

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 truth. 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")

Note: Due to the rapid pace of zoltr development, CRAN version lags behind development. We highly suggest you install the development version to get the latest features.

Getting started

For those starting out we recommend you begin with the “Getting Started” vignette.

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() or project_info().

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=2024-06-27 15:55:21 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"        "is_public"    "name"        
#>  [6] "description"  "home_url"     "logo_url"     "core_data"    "truth"       
#> [11] "model_owners" "models"       "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 were formerly found in a Word document (“flu_challenge_2016-17_update.docx”) that’s since been deleted. From that document’s “Objectives” section:

For each week during the season, participants will be asked to provide national and regional probabilistic forecasts for the entire influenza season (seasonal targets) and for the next four weeks (four-week ahead targets). The seasonal targets are the onset week, the peak week, and the peak intensity of the 2016-2017 influenza season. The four-week ahead targets are the percent of outpatient visits experiencing influenza-like illness (ILI) one week, two weeks, three weeks, and four weeks ahead from date of the forecast.

Copy Link

Version

Install

install.packages('zoltr')

Monthly Downloads

476

Version

1.0.2

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Matthew Cornell

Last Published

March 6th, 2025

Functions in zoltr (1.0.2)

create_project

Create a project
busy_poll_job

Poll job's status
forecast_data_from_cdc_csv_file

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

Edit a model
download_forecast

Gets a forecast's data
do_zoltar_query

A convenience function to construct and execute a Zoltar query for either forecast or truth data.
latest_forecasts

Get a project's latest_forecasts
job_info_forecast_url

Get a new forecast upload's url
forecasts

Get a model's forecasts
quantile_data_frame_from_forecast_data

Converts forecast data from Zoltar's native list format to a quantile data.frame
get_resource

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

Submit a query
model_info

Get information about a model
delete_model

Delete a model
delete_project

Delete a project
forecast_data_from_cdc_data_frame

forecast_data_from_cdc_csv_file() helper
new_connection

Get a connection to a Zoltar host
timezero_info

Get information about a timezero
create_model

Create a model
project_info

Get information about a project
timezeros

Get a project's timezeros
projects

Get information about all projects
%>%

Pipe operator
models

Get a project's models
forecast_info

Gets a forecast's information
unit_info

Get information about a unit
truth_info

Get information about a project's truth
zoltar_units

Get a project's zoltar_units
zoltar_authenticate

Log in to a Zoltar host
zoltr-package

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

Gets a job's file's data
targets

Get a project's targets
delete_forecast

Delete a forecast
data_frame_from_forecast_data

Converts forecast data from Zoltar's native list format to a data.frame
target_info

Get information about a target
upload_forecast

Upload a forecast
job_info

Get a job's information
upload_truth

Upload truth data
create_timezero

Create a timezero