Skip to content

Update documentation, remove endpoint not yet served #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export(covid_hosp_state_timeseries)
export(covidcast)
export(covidcast_epidata)
export(covidcast_meta)
export(covidcast_nowcast)
export(delphi)
export(dengue_nowcast)
export(ecdc_ili)
Expand Down
21 changes: 21 additions & 0 deletions R/.Rapp.history
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
library("devtools")
devtools:document()
devtools::document()
devtools::document()
devtools::check()
.Last.error.trace
install.packages("markdown")
library(markdown)
devtools::document()
devtools::check()
install.packages("Pandoc")
2
install.packages("pandoc")
devtools::document()
devtools::check()
library(Pandoc)
library(pandoc)
devtools::document()
devtools::check()
Sys.getenv("RSTUDIO_PANDOC")
export RSTUDIO_PANDOC=/Applications/RStudio.app/Contents/MacOS/pandoc
149 changes: 46 additions & 103 deletions R/endpoints.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,25 @@ pvt_cdc <- function(auth, epiweeks, locations) {

#' fetch COVID hospitalization facility identifiers
#'
#' API docs: https://cmu-delphi.github.io/delphi-epidata/api/covid_hosp_facility_lookup.html
#' Obtains unique identifiers and other metadata for COVID hospitalization facilities of interest. This is a companinon endpoint to the [covid_hosp_facility()] endpoint.
#'
#' @details Only one argument needs to be specified. Combinations of the arguments are not currently supported. For instance, specifying both city and state are not supported.
#'
#' @examples
#' \donttest{
#' # can take a few minutes; donttesting while backend performance is being improved
#' call <- covid_hosp_facility_lookup(state = "fl")
#' fetch_csv(call)
#' }
#' @param state optional character state
#' @param ccn optional character ccn
#' @param city optional character city
#' @param zip optional numeric zip code
#' @param fips_code optional numeric fips code
#' @return an instance of epidata_call
#' @param state A two-letter character string state abbreviation.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With fix from #74, maybe this could be a character vector.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto for probably every instance of "character string" below.

#' @param ccn A character string for facility CMS certification number.
#' @param city A characater string for city name.
#' @param zip A numeric 5-digit zip code.
#' @param fips_code A numeric 5-digit fips county code.
#' @return an instance of epidata_call.
#'
#' @references API documentation: <https://cmu-delphi.github.io/delphi-epidata/api/covid_hosp_facility_lookup.html>
#'
#' @seealso [covid_hosp_facility()]
#'
#' @export
covid_hosp_facility_lookup <-
Expand Down Expand Up @@ -137,16 +142,23 @@ covid_hosp_facility_lookup <-

#' fetch COVID hospitalization data for specific facilities
#'
#' API docs: https://cmu-delphi.github.io/delphi-epidata/api/covid_hosp_facility_lookup.html
#' Obtains the COVID-19 reported patient impact and hospital capacity data by facility. This dataset is provided by the US Department of Health & Human Services via healthdata.gov.
#'
#' @details Starting October 1, 2022, some facilities are only required to report annually. The companion function [covid_hosp_facility_lookup()] can be used to look up facility identifiers in a variety of ways.
#'
#' @examples
#' call <- covid_hosp_facility(hospital_pks = "100075", collection_weeks = epirange(202001, 202005))
#' call <- covid_hosp_facility(hospital_pks = "100075", collection_weeks = epirange(20200101, 20200501))
#' fetch_csv(call)
#' @param hospital_pks character hospitals to fetch
#' @param collection_weeks epirange weeks to fetch
#' @param publication_dates optional epirange publication dates to fetch
#' @param hospital_pks A character string of facility unique identifiers
#' @param collection_weeks Takes in the form epirange(startdate,enddate), where startdate and enddate are of the form YYYYMMDD (can be passed as string or numeric).
#' @param publication_dates An optional epirange publication dates to fetch, using epirange(startdate,enddate).
#' @return an instance of epidata_call
#'
#' @references API documentation: <https://cmu-delphi.github.io/delphi-epidata/api/covid_hosp_facility.html>
#'
#' See also the official description and data dictionary at <healthdata.gov> for more information.
#'
#' @seealso [covid_hosp_facility_lookup()], [epirange()]
#' @export
#
covid_hosp_facility <-
Expand Down Expand Up @@ -557,10 +569,15 @@ covid_hosp_state_timeseries <-

#' fetch covidcast meta data
#'
#' API docs: https://cmu-delphi.github.io/delphi-epidata/api/covidcast_meta.html
#' Fetch a summary of metadata for all sources and signals that are available in the API, along with basic summary statistics such as the dates they are available, the geographic levels at which they are reported, and etc. For more details, see documentation at <https://cmu-delphi.github.io/delphi-epidata/api/covidcast_meta.html>.
#'
#' @return an instance of epidata_call
#'
#' @examples
#' call_meta <- covidcast_meta()
#' fetch_classic(call_meta)
#'
#' @seealso [covidcast()]
#' @export
covidcast_meta <- function() {
create_epidata_call(
Expand Down Expand Up @@ -588,88 +605,6 @@ covidcast_meta <- function() {
)
}


#' fetch covidcast_nowcast data
#'
#' Not an active endpoint yet.
#'
#' @param data_source data source to fetch
#' @param signals data source to fetch
#' @param sensor_names sensor names to fetch
#' @param time_type data source to fetch
#' @param time_values data source to fetch
#' @param geo_type geo_type to fetch
#' @param geo_values data source to fetch
#' @param as_of data source to fetch
#' @param issues data source to fetch
#' @param lag data source to fetch
#' @return an instance of epidata_call
#'
#' @export
covidcast_nowcast <-
function(data_source,
signals,
sensor_names,
time_type,
geo_type,
time_values,
geo_values,
as_of = NULL,
issues = NULL,
lag = NULL) {
# Check parameters
if (missing(data_source) ||
missing(signals) ||
missing(sensor_names) ||
missing(time_type) ||
missing(geo_type) ||
missing(time_values) || missing(geo_values)) {
stop(
paste0(
"`data_source`, `signals`, `sensor_names`, `time_type`, `geo_type`, `time_values`, ",
"and `geo_value` are all required"
)
)
}
if (!missing(issues) && !missing(lag)) {
stop("`issues` and `lag` are mutually exclusive")
}
check_single_string_param("data_source", data_source)
check_string_param("signals", signals)
check_string_param("sensor_names", sensor_names)
check_single_string_param("time_type", time_type)
check_single_string_param("geo_type", geo_type)
check_epirange_param("time_values", time_values)
check_string_param("geo_values", geo_values)
check_single_epirange_param("as_of", as_of, FALSE)
check_epirange_param("issues", issues, FALSE)
check_single_int_param("lag", lag, FALSE)

create_epidata_call(
"covidcast/",
list(
data_source = data_source,
signals = signals,
sensor_names = sensor_names,
time_type = time_type,
geo_type = geo_type,
time_values = time_values,
geo_values = geo_values,
as_of = as_of,
issues = issues,
lag = lag
),
list(
create_epidata_field_info("geo_value", "text"),
create_epidata_field_info("signal", "text"),
create_epidata_field_info("time_value", "date"),
create_epidata_field_info("issue", "date"),
create_epidata_field_info("lag", "int"),
create_epidata_field_info("value", "float")
)
)
}

#' fetch covidcast data
#'
#' API docs: https://cmu-delphi.github.io/delphi-epidata/api/covidcast.html
Expand All @@ -684,16 +619,24 @@ covidcast_nowcast <-
#' geo_values = "ca,fl"
#' )
#' fetch_csv(call)
#' @param data_source data source to fetch
#' @param signals data source to fetch
#' @param time_type data source to fetch
#' @param time_values data source to fetch
#' @param geo_type geo_type to fetch
#' @param geo_values data source to fetch
#' @param data_source A character string representing a data source to query: (1) fb-survey; (2) jhu-csse; (3) google-symptoms; (4) doctor-visits; (5) quidel; (6) hhs. For more information about each data source, see <https://cmu-delphi.github.io/delphi-epidata/api/covidcast_signals.html>.
#' @param signals A character string representing signals from a specific source to query. A list of available signals for each data source can be found in <https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals>. Each data source may have different signals.
#' @param time_type Temporal resolution of the data. Most signals are available at time_type = "day" resolution. Some signals are only available at the time_type = "week" resolution.
#' @param geo_type A character string that specifies geographic types: (1) county; (2) hrr, hospital referral region; (3) hhs; (4) msa, metropolitan statistical area; (5) dma, designated market areas; (6) state; (7) nation. See <https://cmu-delphi.github.io/delphi-epidata/api/covidcast_geography.html> for details on which types are available for each data source.
#' @param time_values Takes in the form epirange(startdate,enddate), where startdate and enddate are of the form YYYYMMDD (can be passed as string or numeric).
#' @param geo_values A character string that specified which geographies to return. "*" fetches all geographies. To fetch specific geographies, specify their IDs as a vector or a list of strings. More information can be found in <https://cmu-delphi.github.io/delphi-epidata/api/covidcast_geography.html>.
#' @param as_of data source to fetch
#' @param issues data source to fetch
#' @param lag data source to fetch
#' @return an instance of epidata_call
#' @return an instance of `epidata_call`
#'
#' @references COVIDcast API documentation: <https://cmu-delphi.github.io/delphi-epidata/api/covidcast.html>
#'
#' Documentation for all COVIDcast sources and signals: <https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals>
#'
#' COVIDcast public dashboard: <https://delphi.cmu.edu/covidcast/>
#'
#' @seealso [covidcast_meta()], [epirange()]
#'
#' @export
covidcast <-
Expand Down
4 changes: 2 additions & 2 deletions R/model.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' builds a new EpiRange instances
#'
#' @param from start
#' @param to end
#' @param from A string or numeric that takes the form YYYYMMDD.
#' @param to A string or numeric that takes the form YYYYMMDD.
#' @return EpiRange instance
#'
#' @export
Expand Down
21 changes: 16 additions & 5 deletions man/covid_hosp_facility.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 16 additions & 8 deletions man/covid_hosp_facility_lookup.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 17 additions & 7 deletions man/covidcast.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion man/covidcast_meta.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading