bupaverse / bupaR

Core R package for business process analysis
http://www.bupar.net
Other
56 stars 6 forks source link

Error in act_collapse and filter_flow_time functions working with activity log #63

Closed RobertoTCo closed 7 months ago

RobertoTCo commented 1 year ago

Hi, I have found some errors trying to apply functions from the tutorial docs of bupaR, comparing the synthetic datasets 'patients' and 'patients_act'. The following functions, act_collapse() and filter_flow_time() work perfectly with event logs, but they seem to fail with activity logs.

The rdocumentation for the function act_collapse() tells this function should support activitylogs but it looks like it doesn't. However act_unite(), a similar function, works well.

For example, you can compare using the event log and the activity log for patients.

  1. patients %>% act_collapse(Examination = c("Blood test","MRI SCAN","X-Ray"))
  2. patients_act %>% act_collapse(Examination = c("Blood test","MRI SCAN","X-Ray")) or patients %>% to_activitylog() %>% act_collapse(Examination = c("Blood test","MRI SCAN","X-Ray"))

The second one returns:

Error inbind_rows(): ! Can't combine..1$activity_instance_id_by_bupar<integer> and..2$activity_instance_id_by_bupar<character>.

Backtrace: ` ▆

  1. ├─patients_act %>% ...
  2. ├─bupaR::act_collapse(...)
  3. ├─bupaR:::act_collapse.activitylog(...)
  4. │ ├─bupaR::to_activitylog(...)
  5. │ └─bupaR:::act_collapse.eventlog(to_eventlog(log), ..., method)
  6. │ └─bupaR:::aggregate_subprocess_entry_points(...)
  7. │ ├─base::suppressWarnings(...)
  8. │ │ └─base::withCallingHandlers(...)
  9. │ └─... %>% re_map(mapping)
    1. ├─bupaR::re_map(., mapping)
    2. │ └─bupaR::eventlog(...)
    3. └─dplyr::bind_rows(., aggregation)`

For filter_flow_time(), you can compare:

  1. patients %>% filter_flow_time(from = "Blood test", to = "MRI SCAN", interval = c(0,1), units = "days") %>% cases()
  2. patients_act %>% filter_flow_time(from = "Blood test", to = "MRI SCAN", interval = c(0,1), units = "days") %>% cases() or patients_act %>% to_activitylog() %>% filter_flow_time(from = "Blood test", to = "MRI SCAN", interval = c(0,1), units = "days") %>% cases()

Applying the function in the activity log returns:

Error in if (mapping[[i]] %in% renames) mapping[[i]] <- names(renames)[which(renames ==  : 
  the condition has length > 1

There might be some other functions that return errors with activity log, I have been working for a while with the package and I haven't found any other. These are the version of the bupaverse packages I was working with:

[1] processcheckR_0.1.4 processmapR_0.5.2 eventdataR_0.3.1 edeaR_0.9.3 bupaR_0.5.3
[6] bupaverse_0.1.0

gertjanssenswillen commented 1 year ago

Hi @RobertoTCo

Thanks for notifying. We are currently releasing a new version on CRAN, and these errors will probably still be present, but we will fix them for the next release, and perhaps sooner on GitHub

gertjanssenswillen commented 7 months ago

Both problems solved in bupaR 0.5.4