Learn R Programming

tabledown (version 1.0.0)

bedTime: A Function for calculating time spent in bed.

Description

This function will help you to calculate the time a person spent in bed based on their sleep log. This type of calculation is very common in sleep research. However, as one can guess, working with dates in R is a bit tricky. This function will ease the task. More importantly you do not require to entry the dates to calculate bed time. Just wake up time and time to go to bed is enough (24 hour format).

Usage

bedTime(x, y)

Value

Calculates time spent in bed in hours. Output class is numeric.

Arguments

x

A vector containing time to do to bed.

y

A vector containing time of wake.

Examples

Run this code
#Please use 24 hour format.
#Easiest way is to enter the data as character.
bed <-c("20:00", "21:00", "23:00")
wake <-c("6:00", "7:00", "8:00")
bedtime <- bedTime(bed, wake)

Run the code above in your browser using DataLab