read_data: Read data from csv files

Description Usage Arguments Details Value Examples

Description

read_data takes a directory and file name and reads in all matching csv files and binds them together into a data frame

Usage

1
read_data(data.dir, file.name, edw = TRUE, archive = FALSE)

Arguments

data.dir

A character string with the name of the directory containing the data files

file.name

A character string with name of data file or pattern to match

edw

A boolean indicating if the data came from EDW; set to FALSE for

archive

A boolean indicating if the data was extracted as a csv archive. If TRUE, will recursively search folders for csv files and will skip the first line for column headers

Details

This function takes a directory and file name and reads in all matching csv files and binds them together into a data frame using read_csv from readr. The resulting data frame has a class of edwr, and can then be passed to one of the edwr-related class types for variable renaming and type setting (example: as.labs).

The following table lists the edwr-related class which corresponds to each EDW Standard Project Queries.

edwr Class Name --- EDW Query Name
blood Blood Products
charges Charges - [All, Department Prompt]
demographics Demographics
diagnosis Diagnosis Codes (ICD-9/10-CM) - All
drg DRG Codes - All
encounters Encounters - by Person ID
events Clinical Events - Prompt
icu_assess ICU Assessments (CAM-ICU, GCS, RASS)
id Identifiers - by FIN
Identifiers - by MRN
Identifiers - by PowerInsight Encounter Id
labs Labs - ABG
Labs - CBC
Labs - Chemistry
Labs - Coags
Labs - HIT
Labs - LFTs
Labs - Pregnancy
Labs - Renal
Urine Drug Screen
Vomiting Output
locations Location History
measures Measures (Height and Weight)
meds_cont Medications - Inpatient Continuous - [All, Prompt]
meds_freq Medications - Inpatient Intermittent with Frequency - [All, Prompt]
meds_home Medications - Home and Discharge - [All, Prompt]
meds_sched Medications - Inpatient Intermittent - [All, Prompt]
mpp MPP's Ordered - [All, Order Prompt]
mrn Identifiers - Person by MRN
order_by Orders - Prompt
order_detail Orders - from Clinical Event Id - Prompt
patients Patients - by CDM charge - HealthQuest - [Location Prompt, System]
Patients - by ICD-9/10-CM Diagnosis Code
Patients - by Medication
Patients - by Unit Admission
problems Problem List
procedures Procedure Codes (ICD-9-CM/ICD-10-PCS) - All
radiology Radiology Reports
services Service History
surgeries Surgeries
uop Urine output
vent_settings Ventilator Data - Settings
vent_times Ventilator Data - Start and Stop
visits Visit Data
vitals Vitals
warfarin Warfarin Information

Value

A data frame of class tbl_edwr

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
x <- read_data(
  data.dir = paste0(system.file(package = "edwr", "extdata")),
  file.name = "demographics.csv"
)

str(x)
class(x)

y <- as.demographics(x)
class(y)

bgulbis/edwr documentation built on May 12, 2019, 8:22 p.m.