db_get_from_table: Simple generic SELECT * wrapper for extracting data from base...

Description Usage Arguments Value Examples

View source: R/db_get.R

Description

Helper function to perform a basic SELECT * from the noted table projected down by the optional where clause. Note that some internal processing is performed to reflect general usage patterns including removing the ROW_ID column and converting DATE and TIME fields to POSIXct date-time format.

Usage

1
db_get_from_table(con, table, where = NULL)

Arguments

con

A DBIConnection object, as returned by dbConnect().

table

a character string representing a valit MIMIC-III table name.

where

a character string representing a SQL WHERE clause.

Value

a tibble with the results.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
con <- RSQLite::dbConnect(RSQLite::SQLite(), ":memory:")
p <- tibble::tibble(SUBJECT_ID = c(10006, 10011))
a <- tibble::tibble(SUBJECT_ID = c(10006, 10011))
RSQLite::dbWriteTable(con, "PATIENTS", p)
RSQLite::dbWriteTable(con, "ADMISSIONS", a)

patients <- db_get_from_table(con, "PATIENTS")
admissions <- db_get_from_table(con, "ADMISSIONS", where = "WHERE SUBJECT_ID = 10006")

RSQLite::dbDisconnect(con)

hdshea/MIMIC3db documentation built on Dec. 20, 2021, 3:44 p.m.