combine_summary and combine_daily

These functions are designed for the situation where you have multiple sets of output from GGIR, and want to combine them into a single dataset. When you have run analysis of your actigraphy data using GGIR, you end up with a folder containing several csv files full of data, as shown below.

library(knitr)
include_graphics("output_files.PNG")

You may be in a position where you have many of these folders, and want to combine GGIR output without having to search through different output folders to find the right files to combine. These functions are designed to save time by creating a single dataset for each output part (i.e. part 2, 4, and 5) containing data from all participants.

combine_summary

This function takes the 'summary' parts of the GGIR output and combines them. It takes two arguments: the filepath to the folder containing all of your output, and the part of the output you want (2, 4, or 5). I recommend having all your output folders containing data you want to combine in a single folder, and setting your working directory to the directory containing this folder.

In this example, the folder containing the data we are interested in is named 'Output' and we are interested in the data produced in the part 5 summary.

mydata <- combine_summary(filepath = "Output", part = 5)
include_graphics("summary_result.PNG")

You can then conduct your analysis in R. Alternatively you can make a new csv file with the output, e.g. write.csv(mydata, file = "mydata.csv").

combine_daily

This function works in exactly the same way as combine_summary, but works for the daily output parts- i.e. part2_daysummary, part4_nightsummary and part5_daysummary.

mydata <- combine_daily(filepath = "Output", part = 5)
include_graphics("daily_result.PNG")

all_summary and all_daily

These functions are designed for when you have a single set of output from GGIR (i.e. 3 daily and 3 summary .csv files) and want to combine them so that you have just one dataset for summary values, and one for daily values.

all_summary takes one argument, which is the filepath to the GGIR output folders containing the data you want to combine. It combines part2_summary, part4_summary_sleep_cleaned, and part5_personsummary by ID, after fixing inconsistencies between the output parts.

summary_data <- all_summary(filepath = "Study_Results/output_2019_test")

all_daily works in the same way, but for part2_daysummary, part4_nightsummary_sleep_cleaned, and part5_daysummary. It matches datasets by both ID and measurement day.

daily_data <- all_daily(filepath = "Study_Results/output_2019_test")

NB These functions rely on the names of the output parts being in their standard form. If you have changed the names of the output files, they will probably not work.



amyr-hodgson/easyGGIR documentation built on Nov. 2, 2019, 1:46 p.m.