This vignette will describe how to clean users' log files using functions provided in the adapter package.

Logs to clean

Cleaning requires user log files to have been read into R in the appropriate format. For details about how to read in log files so that they can be cleaned using adapter functions, please read the Vignette on Reading log files.

To demonstrate, the following will read in a list of user log files using the read_all() function:

# Create path to all user data (this is specific to this document, you'll need to create your own)
path_to_user_data <- system.file("extdata", "eg_user_list", package = "adapter")

# Load adapter package and read all user's log files
library(adapter)
d <- read_all(path_to_user_data, clean = FALSE, calculate = FALSE)  # Turn cleaning off so that we can do it separately

We will use our list of user data, d, in forthcoming analyses.

For later comparisons, here is the uncleaned data for one user in this list:

d[[1]]

Functions for cleaning log files

The adapter package provides the following functions for cleaning log files:

We'll cover these below.

Cleaning with clean_laps()

The purpose of clean_laps() is to:

To use clean_laps() most efficiently, pass it a list of user data created via read_all. For example, using d from above:

clean_d <- clean_laps(d)

Lets now compare the data for the first user:

clean_d[[1]]

If you compare to the uncleaned version above, you'll notice that there are fewer rows in the events and streams tibbles. This is because data before lap 1 started and after lap 5 ended has been removed. You'll also notice that there is a lap column in both of these tibbles.

As a side note, clean_laps() will work on a single driver user's list. However, to handle drone operators, it must have the complete user list. This is because the drone operator information needs to come from his/her driver teammate (where lap information is logged originally).

Cleaning with clean_events()

The purpose of clean_events() is to add boolean (logical TRUE/FALSE) columns to the events and stream tibbles that capture when certain events are happening. The function will add a new boolean column for each type of event, which will be TRUE at times during which the driver in the team was within the boundaries of the trigger box collider defining the event.

To use clean_events() most efficiently, pass it a list of user data created via read_all. For example, using d from above:

clean_d <- clean_events(d)
clean_d[[1]]

Notice the boolean columns on the right for each event.



drsimonj/adapter documentation built on May 15, 2019, 2:51 p.m.