save_db: Save a list of UK Biobank data schemas to an SQLite database

Description Usage Arguments Details Value Examples

View source: R/save-db.R

Description

save_db() saves a list of UK Biobank data schemas (or, if as_is == TRUE, any list of tibbles) to an SQLite database

Usage

1
2
save_db(sch, file = "", path = ".", date_str = Sys.Date(),
  silent = !interactive(), overwrite = FALSE, as_is = FALSE)

Arguments

sch

List of tibbles, representing UK Biobank data schemas (unless as_is == TRUE, in which case any list of tibbles is permitted)

file

The filename for the schema database. Defaults to "", which is interpreted as paste0("ukb-schemas-", date, ".sqlite"). If this file already exists in directory path, the session is interactive, and overwrite is not FALSE, then the user will be prompted to decide whether the file should be overwritten.

path

The path to the directory where the file will be saved. Defaults to . (the current directory).

date_str

The date-stamp for the default filename. Defaults to the current date in YYYY-MM-DD format.

silent

Do not report progress. Defaults to FALSE.

overwrite

Always overwrite existing files? Helpful for non-interactive use. Defaults to FALSE.

as_is

Import the schemas into the database without tidying? Defaults to FALSE.

Details

save_db() takes a list of UK Biobank schemas and saves them to an SQLite database. If !as_is, they are tidied. Note that if the table structure has changed (i.e. has been changed by UK Biobank), then the function may fail partially or fully unless as_is == TRUE.

Value

A database connection object of class RSQLite::SQLiteConnection.

Examples

1
2
3
4
5
## Not run: 
sch <- ukbschemas()
db <- save_db(sch, path = tempdir())

## End(Not run)

bjcairns/ukbschemas documentation built on Nov. 4, 2019, 7:22 a.m.