<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/bupar-business-process-analysis-with-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://businessinformatics.be/2017/09/29/bupar-business-process-analysis-with-r/"> R – Research group Business Informatics</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Organizations are nowadays storing huge amounts of data related to various business processes. Process mining provides different methods and techniques to analyze and improve these processes. This allows companies to gain a competitive advantage. Process mining initiated with the discovery of work-flow models from event data. However, over the past 20 years, the process mining field has evolved  into a broad and diverse research discipline.</p>
<p><span></span></p>
<p>bupaR is an open-source suite for the handling and analysis of business process data in R. It was developed by the Business Informatics research group at Hasselt University, Belgium. The central package includes basic functionality for creating event log objects in R. It contains several functions to get information about an event log and also provides specific event log versions of generic R functions. Together with the related packages, each of which has their own specific purpose, bupaR aims at supporting each step in the analysis of event data with R, from data import to online process monitoring.</p>
<p><img sizes="(max-width: 584px) 100vw, 584px" src="https://i1.wp.com/businessinformatics.be/wp-content/uploads/2017/09/workflow-1024x338.png?w=450" alt="" class="wp-image-270" data-recalc-dims="1"></p>
<p>The table below shows an example event log. Each row is an event which belongs to a <strong>case</strong> (<em>a</em> <em>patient</em>). Different events together can form an <strong>activity instance</strong>, or execution (e.g. event 2-4 belong to <em>surgery 2). </em>Each event in such an execution will have a different transactional <strong>lifecycle</strong> status. Note that there can be different instances of a specific <strong>activity</strong> (e.g. there are two surgeries in the example). Furthermore, each event has a <strong>timestamp</strong>, indicating when it happened, and a <strong>resource</strong>, indicating who performed it.</p>
<p><img sizes="(max-width: 889px) 100vw, 889px" src="https://i2.wp.com/businessinformatics.be/wp-content/uploads/2017/09/example_eventlog.png?w=450" alt="" class="wp-image-261" data-recalc-dims="1"></p>
<p>Given that the data shown above is stored in a data.frame, it can be turned into an event log object by indicating all the relevant data fields.</p>
<pre>library(bupaR) 
data %>%
 eventlog(
   case_id = &quot;patient&quot;,
   activity_id = &quot;activity&quot;,
   activity_instance_id = &quot;activity_instance&quot;,
   lifecycle_id = &quot;status&quot;,
   timestamp = &quot;timestamp&quot;,
   resource_id = &quot;resource&quot;
 )</pre>
<p>Alternatively, event data can be read from XES-files. <a rel="nofollow" href="http://www.xes-standard.org/" target="_blank">XES, eXtensible Event Stream</a> notation, is the IEEE standard for storing and sharing event data. The <a rel="nofollow" href="https://cran.r-project.org/web/packages/xesreadR/index.html" target="_blank">xesreadR </a>package, which is part of bupaR, provides the functions <em>read_xes</em> and <em>write_xes</em> as an interface between R and XES-files. The following statement shows how to read an event log from a xes-file, in this case with data on an order-to-cash (otc) process.</p>
<pre>log_otc &lt;- read_xes(&quot;otc.xes&quot;)</pre>
<p>Event log objects can be visualized with <a rel="nofollow" href="https://cran.r-project.org/web/packages/processmapR/index.html" target="_blank">processmapR</a>. It allows the user to create a customizable <em>dotted chart</em>, showing all the events by time and case identifier in one graph. Precedence relations between activities can also be shown with a <em>process map</em>. Frequent traces, i.e. activity sequences, can be explored with the <em>trace_explorer</em>.</p>
<pre>log_otc %>% 
 dotted_chart</pre>
<p><img sizes="(max-width: 681px) 100vw, 681px" src="https://i1.wp.com/businessinformatics.be/wp-content/uploads/2017/09/dotted_chart.png?w=450" alt="" class="wp-image-264" data-recalc-dims="1"></p>
<pre>log_otc %>%
 filter_trace_frequency(perc = 0.9) %>%
 process_map()</pre>
<p><img sizes="(max-width: 391px) 100vw, 391px" src="https://i2.wp.com/businessinformatics.be/wp-content/uploads/2017/09/processmap.png?resize=391%2C480" alt="" class="wp-image-265" data-recalc-dims="1"></p>
<pre>log_otc %>% 
  trace_explorer(coverage = 0.9)</pre>
<p><img sizes="(max-width: 709px) 100vw, 709px" src="https://i2.wp.com/businessinformatics.be/wp-content/uploads/2017/09/trace_explorer.png?w=450" alt="" class="wp-image-266" data-recalc-dims="1"></p>
<p><a rel="nofollow" href="https://cran.r-project.org/web/packages/edeaR/index.html" target="_blank">edeaR</a> stands for Exploratory and Descriptive Event-Data Analysis. This package provides several metric functions for in-depth analysis of event logs, as well as a diverse set of subsetting methods. The functions can be calculated at a varying number of granularity levels, allowing to drill-down in the data and focus on a specific part. Furthermore, all metrics are compatible with <em>dplyr::group_by.</em> The generic plot functions can be used to create predefined graphs, which can be customized using ggplot2.</p>
<p><img sizes="(max-width: 248px) 100vw, 248px" src="https://i1.wp.com/businessinformatics.be/wp-content/uploads/2017/09/edear_functions-248x300.png?resize=248%2C300" alt="" class="wp-image-268" data-recalc-dims="1"></p>
<p>The example below shows in how many cases each of the activities is present. This shows that in the given event log, there is a set of very common activities, and a set of very rare activities.</p>
<pre>log_otc %>% activity_presence %>% plot</pre>
<p><img sizes="(max-width: 584px) 100vw, 584px" src="https://i1.wp.com/businessinformatics.be/wp-content/uploads/2017/09/activity_presence-1024x389.png?w=450" alt="" class="wp-image-269" data-recalc-dims="1"></p>
<p>Next to the metrics, also a varied set of event-data specific subsetting methods are provided. All the functions are designed to work together with the piping symbol.</p>
<p><img sizes="(max-width: 300px) 100vw, 300px" src="https://i1.wp.com/businessinformatics.be/wp-content/uploads/2017/09/filters-300x298.png?resize=300%2C298" alt="" class="wp-image-267" data-recalc-dims="1"></p>
<p>Next to the packages discussed above, there is also the <a rel="nofollow" href="https://cran.r-project.org/web/packages/eventdataR/index.html" target="_blank">eventdataR </a>package which contains example event datasets and the <a rel="nofollow" href="https://cran.r-project.org/web/packages/processmonitR/index.html" target="_blank">processmonitR </a>package which provides predefined dashboards for online process monitoring. For more information about bupaR, you can visit the <a rel="nofollow" href="http://bupar.net/" target="_blank">website</a> where you can also find a <a rel="nofollow" href="http://bupar.net/materials/20170904%20poster%20bupaR.pdf" target="_blank">cheat sheet</a>.</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://businessinformatics.be/2017/09/29/bupar-business-process-analysis-with-r/"> R – Research group Business Informatics</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/bCteGodmpIM" height="1"></a></div>