Running examples in ‘daiquiri-Ex.R’ failed
The error most likely occurred in:

> ### Name: aggregate_data
> ### Title: Aggregate source data
> ### Aliases: aggregate_data
> 
> ### ** Examples
> 
> ## Don't show: 
>   # restrict threads for CRAN compliance
>   dt_threads <- data.table::getDTthreads()
>   data.table::setDTthreads(1)
> ## End(Don't show)
> 
> # 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")
+ )
field_types supplied:
PrescriptionID	<uniqueidentifier>
PrescriptionDate	<timepoint>	options: includes_time
AdmissionDate	<datetime>
Drug	<freetext>
Dose	<numeric>
DoseUnit	<categorical>
PatientID	<ignore>
Location	<categorical>	options: aggregate_by_each_category
 
Checking column names against field_types... 
Importing source data [raw_data]... 
Removing column-specific na values... 
Checking data against field_types... 
  Selecting relevant warnings... 
  Identifying nonconformant values... 
  Checking and removing missing timepoints... 
Checking for duplicates... 
  Sorting data... 
Loading into source_data structure... 
  PrescriptionID 
  PrescriptionDate 
  AdmissionDate 
  Drug 
  Dose 
  DoseUnit 
  PatientID 
  Location 
Finished 
> 
> # aggregate the data
> aggregated_data <- aggregate_data(
+   source_data,
+   aggregation_timeunit = "day"
+ )
Aggregating [] by [day]... 
Aggregating overall dataset... 
Aggregating each data_field in turn... 
1: PrescriptionID 
Preparing... 
Aggregating character field... 
  By n 
Error in `[.data.table`(grouped_values, data_field_dt[, list(value = eval(agg_fun$function_call)),  : 
  attempt access index 1/1 in VECTOR_ELT
Calls: aggregate_data ... aggregate_and_append_values_simple -> [ -> [.data.table
Execution halted