get_relationships: Download relationships from Go.Data

View source: R/get_relationships.R

get_relationshipsR Documentation

Download relationships from Go.Data

Description

A function to retrieve the relationship data for a specific outbreak_id.

Usage

get_relationships(
  url,
  username,
  password,
  outbreak_id,
  method = c("export", "batch"),
  batch_size = 50000,
  wait = 2,
  file_type = c("json", "csv")
)

Arguments

url

Insert the base URL for your instance of Go.Data here. Don't forget the forward slash "/" at end!

username

The email address for your Go.Data login.

password

The password for your Go.Data login

outbreak_id

The id number for the outbreak for which you want to download data.

method

The method to download data. method = "export" is the preferred and default method for Go.Data version 2.38.1 or later. See Details.

batch_size

If method = "batches", then batch_size specifies the number of records to retrieve in each iteration.

wait

If method = "export", then wait is the number of seconds to wait in between iterations of checking the status of the export.

file_type

If method = "export", then file_type determines Whether the resulting data frame should contain nested fields (file_type = "json", the default) or an entirely flat data structure (file_type = "csv")

Details

This function works on all versions of Go.Data. There are two methods for downloading the data:

method = "batches" will work on all versions of Go.Data. This method relies on the GET outbreak/id/relationships API endpoint. Records are then retrieved in batches based on batch_size and appended together into a final dataset. method = "batches" will be the default and only available method for Go.Data version 2.38.0 or older.

method = "export" will only work on Go.Data versions 2.38.1 or newer. This method relies on the GET outbreak/id/relationships/export API endpoint. An export request is submitted to the server, and then when the export is ready, it will be downloaded. Due to better performance and more options, method = "export" will be the default if you are using Go.Data version 2.38.1 or newer.

Value

Returns a data frame. Some fields, such as addresses, hospitalization history, and questionnaire fields may require further unnesting. See nest for assitance with unnesting.

Examples

## Not run: 
url <- "https://MyGoDataServer.com/"
username <- "myemail@email.com"
password <- "mypassword"
outbreak_id <- "3b5554d7-2c19-41d0-b9af-475ad25a382b"

relationships <- get_relationships(
  url = url,
  username = username,
  password = password,
  outbreak_id = outbreak_id
)

## End(Not run)

WorldHealthOrganization/godataR documentation built on May 21, 2023, 11:30 a.m.