View source: R/aggregate_data.R
aggregate_data | R Documentation |
Aggregates a daiquiri_source_data
object based on the field_types()
specified at load time.
Default time period for aggregation is a calendar day
aggregate_data(source_data, aggregation_timeunit = "day", show_progress = TRUE)
source_data |
A |
aggregation_timeunit |
Unit of time to aggregate over. Specify one of
|
show_progress |
Print progress to console. Default = |
A daiquiri_aggregated_data
object
prepare_data()
, report_data()
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.