aggregate_data {daiquiri} | R Documentation |
Aggregate source data
Description
Aggregates a daiquiri_source_data
object based on the field_types()
specified at load time.
Default time period for aggregation is a calendar day
Usage
aggregate_data(source_data, aggregation_timeunit = "day", show_progress = TRUE)
Arguments
source_data |
A |
aggregation_timeunit |
Unit of time to aggregate over. Specify one of
|
show_progress |
Print progress to console. Default = |
Value
A daiquiri_aggregated_data
object
See Also
Examples
# load example data into a data.frame
raw_data <- read_data(
system.file("extdata", "example_prescriptions.csv", package = "daiquiri"),
delim = ",",
col_names = TRUE
)
# validate and prepare the data for aggregation
source_data <- prepare_data(
raw_data,
field_types = field_types(
PrescriptionID = ft_uniqueidentifier(),
PrescriptionDate = ft_timepoint(),
AdmissionDate = ft_datetime(includes_time = FALSE),
Drug = ft_freetext(),
Dose = ft_numeric(),
DoseUnit = ft_categorical(),
PatientID = ft_ignore(),
Location = ft_categorical(aggregate_by_each_category = TRUE)
),
override_column_names = FALSE,
na = c("", "NULL")
)
# aggregate the data
aggregated_data <- aggregate_data(
source_data,
aggregation_timeunit = "day"
)
aggregated_data
[Package daiquiri version 1.1.1 Index]