gertjanssenswillen / xesreadR

!! repository moved to https://github.com/bupaverse/xesreadR !! This repo is read-only from now one.
Other
1 stars 2 forks source link

Problem exporting to XES when ANY variable starts with CASE_ in the log #3

Closed carvalhomb closed 5 years ago

carvalhomb commented 5 years ago

When trying to export an event log to XES (function write_xes()), I'm getting the following error message:

  do not know how to convert 'x' to class “POSIXlt”
In addition: Warning message:
Unknown columns: `1` 

The traceback shows:

10: stop(gettextf("do not know how to convert '%s' to class %s", 
        deparse(substitute(x)), dQuote("POSIXlt")), domain = NA)
9: as.POSIXlt.default(x, tz = tz)
8: as.POSIXlt(x, tz = tz)
7: format(as.POSIXlt(x, tz = tz), format = format, usetz = usetz, 
       ...)
6: strftime(value, format = "%Y-%m-%dT%H:%M:%S.000+00:00")
5: addAttribute(trace_attrs[name], name, trace[name])
4: addTrace(trace)
3: addTraces()
2: createXES(xesfile, traces = case_attributes, events = as.data.frame(eventlog), 
       case_classifier = case_id(e))
1: write_xes(event_log, xesfile = file.path("event_log_bupar.xes"))

The column in question is CASE_ID, which has been indicated as the case_id when I converted the data frame to event log.

While I understand that any variable starting with CASE_ is considered as a case attribute when case_attributes is null, I would think that variables that are assigned to other fields would be ignored in this check (also, the code seems to suggest that). However, if I rename CASEID to another name that doesn't start with CASE, I manage to write the log without problems.

Also, it took me a long time to figure out that the problem is with the name of a column, as the error message related to the function as.POSIXIt was throwing me completely off track.

carvalhomb commented 5 years ago

I tried to debug this further by copying the code from functions write_xes() and createXES() to a local script and renaming them so that I could print out intermediate values and see what was going on. Without changing anything in the function, the local version runs without problem, while the package version chokes when there are any case attribute variables, trying to convert them to POSIXlt even when they are not of type "date".

I have no idea why - I made sure I have the latest version of xesreadR installed (0.2.2), reinstalled it, restarted the R session before running anything. My knowledge of R is limited, so I'm not sure how to proceed in trying to pinpoint what is going on.

carvalhomb commented 5 years ago

OK, nevermind, the problem is fixed by commit ee73a8, but that is still not available in the 0.2.2 version in CRAN. Getting the code directly from the repository fixes the issue.

gertjanssenswillen commented 5 years ago

I'm sorry for the delay here. I'll update the package on CRAN right now so that the problem is solved there too.