report_data {daiquiri}R Documentation

Generate report from existing objects

Description

Generate report from previously-created daiquiri_source_data and daiquiri_aggregated_data objects

Usage

report_data(
  source_data,
  aggregated_data,
  report_title = "daiquiri data quality report",
  save_directory = ".",
  save_filename = NULL,
  format = "html",
  show_progress = TRUE,
  ...
)

Arguments

source_data

A daiquiri_source_data object returned from prepare_data() function

aggregated_data

A daiquiri_aggregated_data object returned from aggregate_data() function

report_title

Title to appear on the report

save_directory

String specifying directory in which to save the report. Default is current directory.

save_filename

String specifying filename for the report, excluding any file extension. If no filename is supplied, one will be automatically generated with the format daiquiri_report_YYMMDD_HHMMSS.

format

File format of the report. Currently only "html" is supported

show_progress

Print progress to console. Default = TRUE

...

Further parameters to be passed to rmarkdown::render(). Cannot include any of input, output_dir, output_file, params, quiet.

Value

A string containing the name and path of the saved report

See Also

prepare_data(), aggregate_data(), daiquiri_report()

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"),
  dataset_description = "Example data provided with package",
  show_progress = TRUE
)

# aggregate the data
aggregated_data <- aggregate_data(
  source_data,
  aggregation_timeunit = "day",
  show_progress = TRUE
)

# save a report in the current directory using the previously-created objects
report_data(
  source_data,
  aggregated_data,
  report_title = "daiquiri data quality report",
  save_directory = ".",
  save_filename = "example_data_report",
  show_progress = TRUE
)




[Package daiquiri version 1.1.1 Index]