Import Actiwatch sleep or nap data.
read_msleep.Rd
Importing the raw Actiwatch sleep or nap for each subject.
Arguments
- subject
A character vector denoting the Pregnancy 24/7 subject.
- trimester
A character or integer vector denoting trimester of pregnancy.
- nap
Logical denoting if nap data is to be imported. Default is
FALSE
.- file
Either a path to a file, a connection, or literal data (either a single string or a raw vector). The default value is
NULL
, which uses thesubject
andtrimester
parameters to find the appropriate filename.- ...
Any other parameters needed for
utils::read.csv()
.
Value
A msleep
object, which is a data.frame
containing the imported
Actiwatch sleep or nap data. The exporting of data software by
Actiwatch does not provide useable variable names. So, the variable names
are assigned here by column location. See the vingettes
for details on the
variable names.
Details
Empty strings (""
), missing values (NA
), and not a number
(NaN
) values exported by the Actiwatch device are all considered as
missing values for this importing process.
As the function is meant for the use of the Pittsburgh team, it
assumes all of the subject data is located within a single folder. So, for
appropriate use based on subject
and trimester
only, the working
directory must be the main directory containing the data of each subject
within subject-specific folders based on IDs. It is also assumed the names
of the folders in subject-specific directories are
Visit 1
,Visit 2
, andVisit 3
for each trimester of pregancy.
If file
is provided, then the data is imported based on the file
name
only even though subject
and trimester
are still required.
The exporting data software by Actiwatch provides extraneous data, so the data is imported twice to find the data actually needed.