Skip to contents

A function that exports two types of files locally. 1. A summary of the entire recording (.csv). 2. Daily activity recordings in individual files (.txt). The default deliminator is set to be space, with `.` as the decimal indicator. As such, it should be noted that some transformation may be needed when opening in EXCEL on a computer with non-English EU settings.

Usage

write.act(
  Dir,
  ID,
  df,
  Bdf,
  TUnit = "hour",
  VAct = NULL,
  VTm = NULL,
  Incomplete = FALSE,
  Travel = TRUE,
  Simple = FALSE
)

Arguments

Dir

The directory where the recordings to be exported <e.g. "C:/Users/___YOUR USERNAME___/UPSTREAM FOLDER/.../FOLDER NAME/">

ID

The subject's ID which would be used to create a folder.

df

A data.frame of raw actigraphy recording. Both time and activity count should be included in the `df`. See `VAct` and `VTm` for further detail.

Bdf

A BriefSum object. Note, if jet lag occurred during the recording, please, update the metadata using TAdjust before passing to this function.

TUnit

Character; time–unit for the x–axis of each day's timeline. Must be one of `day`, `hour`, `minute` or `second`. Default is `hour`.

VAct

Optional character. Name of the activity column in `df`. If NULL, defaults to the second column of `df`.

VTm

Optional character. Name of the time index column in `df`. If NULL, defaults to the first column of `df`.

Incomplete

Logical; if TRUE, days flagged `Incomplete Recording` (i.e. <24 h) are retained in the data list with recordings segmented by day. Default = FALSE (these days are removed).

Travel

Logical; if TRUE, days flagged `Travel` are retained although some data points from an earlier adjacent calendar day may be duplicated (a warning is issued). If FALSE, travel days and the day before/after are excluded. Default = TRUE.

Simple

Logical; if TRUE, only columns stored in the original recordings will be exported. If FALSE, all information stored in `df` will be generated. Default = FALSE

Value

Text files ".txt" containing segmented recordings of each day and `Bdf` from BriefSum

  • Text File: Recordings segmented by the recording date

  • Summary: Bdf exported as ".csv" file.

Examples

if (FALSE) { # \dontrun{

# Import data
data (FlyEast)


# Create quick summary of the recording with adjustment for daylight saving.
BdfList <-
    BriefSum (
        df = FlyEast,
        SR = 1 / 60,
        Start = "2017-10-24 13:45:00"
    )

# Let's extract the quick summary of the recording
Bdf <- BdfList$Bdf

### Note that since the original data was affected by travel-induced time
### shift, the recordings would not be properly segmented from 2017-11-02.

## To avoid time shift due to travelling, we will keep only the first 8 days.
Bdf <- Bdf [1:8, ]

df <- BdfList$df
# Export daily recordings and the summary report

write.act (
    Dir = getwd (), ## Export to the current working directory
    ID = "JD",
    df = df,
    Bdf = Bdf,
    VAct = "Activity",
    VTm = "Time"
)

## To see what was exported copy the path generated by the code below and
## paste it as an url in a web browser or the file explorer.
getwd ()
} # }