Several methods are provided to convert common objects (such as data frames) into covidcast_signal objects, which can be used with the various covidcast_signal methods (such as plot.covidcast_signal() or covidcast_cor()). See vignette("external-data") for examples.

as.covidcast_signal(x, ...)

# S3 method for covidcast_signal
as.covidcast_signal(x, ...)

# S3 method for data.frame
as.covidcast_signal(
  x,
  signal = NULL,
  geo_type = c("county", "msa", "hrr", "dma", "state", "hhs", "nation"),
  time_type = c("day", "week"),
  data_source = "user",
  issue = NULL,
  metadata = list(),
  ...
)

Arguments

x

Object to be converted. See Methods section below for details on formatting of each input type.

...

Additional arguments passed to methods.

signal

The signal name to use for this data.

geo_type

The geography type stored in this object.

time_type

The time resolution stored in this object. If "day", the default, each observation covers one day. If "week", each time value is assumed to be the start date of the epiweek (MMWR week) that the data represents.

data_source

The name of the data source to use as a label for this data.

issue

Issue date to use for this data, if not present in x, as a Date object. If no issue date is present in x and issue is NULL, today's date will be used.

metadata

List of metadata to attach to the covidcast_signal object. See the "Metadata" section of covidcast_signal(). All objects will have geo_type, data_source, and signal columns included in their metadata; named entries in this list are added as additional columns.

Value

covidcast_signal object; see covidcast_signal() for documentation of fields and structure.

Methods (by class)

  • as.covidcast_signal(covidcast_signal): Simply returns the covidcast_signal object unchanged.

  • as.covidcast_signal(data.frame): The input data frame x must contain the columns time_value, value, and geo_value. If an issue column is present in x, it will be used as the issue date for each observation; if not, the issue argument will be used. Other columns will be preserved as-is.