The most three commonly used tools to perform a first inspection on activity data are:
Actograms: These are 2D graphs that shows tiled activity during 24h period over several days. These graphs are useful to visualize daily cycles of activities. In actograms, the x-axis represent the day time, the y-axis represent the day and the intensity of the colors represents the activity amplitude.
Average activity plots: these graphs show the average activity for a specific moment of the day. The average is done over all days taking one data point from each day and averaging all the values.
Diurnality index: this type of graphs shows whether the activity tends to be more diurnal or nocturnal. In another word, this shows whether the subject of the study is more active during the day or during the night.
We start by loading a dataset from the library digiRhythm, we then remove the outliers and resample it to 15 min. We choose one activity to study.
library(digiRhythm)
<- digiRhythm::df691b_1
data <- remove_activity_outliers(data)
data <- resample_dgm(data, 15)
data = names(data)[2]
activity head(data)
#> datetime Motion.Index Steps
#> 1 2020-08-25 00:00:00 20 8
#> 2 2020-08-25 00:15:00 52 46
#> 3 2020-08-25 00:30:00 61 39
#> 4 2020-08-25 00:45:00 29 18
#> 5 2020-08-25 01:00:00 83 26
#> 6 2020-08-25 01:15:00 50 23
We then proceed to plot the actogram of the activity. We can choose the start and end date of the actogram. We can also choose an alias for the activity. This alias is used for aesthetics purpose in the plots. For instance, if the name of the activity column is motion.index, we don’t probably want to show this string in the plot’s legend, but rather have it coded properly as ‘Motion Index’. The actogram function also offers the possibility to save then graph directly in a path as shown in the commented line below. Users only provide the path (relative or physical) without the file name ignoring the extension. All pictures in digiRhythm are saved with the tiff format as it’s the most widely used extension for scientific publications.
User have the possibility to save the plot with another extension or configuration simply by saving the actogram object in a variable (which is a ggplot object) and control it as they wish to.
<- "2020-08-25" #year-month-day
start <- "2020-10-11" #year-month-day -->
end <- 'Motion Index'
activity_alias #save <- 'sample_results/actogram' #if NULL, don't save the image
<- actogram(data, activity, activity_alias , start, end, save = NULL) my_actogram
Now, we plot the average activity. We follow the same dataframe and same logic like for the actograms.
<- "2020-08-25" #year-month-day
start <- "2020-10-11" #year-month-day -->
end <- 'Motion Index'
activity_alias #save <- 'sample_results/actogram' #if NULL, don't save the image
<- daily_average_activity(data, activity, activity_alias , start, end, save = NULL) my_daa
The diurnality index could be computed and plotted using the diurnality function as follows.
= c("06:30:00", "16:30:00")
day_time = c("18:00:00", "T05:00:00")
night_time <- diurnality(data, activity,day_time, night_time) my_di