Learn R Programming

mMARCH.AC (version 3.3.4.0)

get_mean_sd_hour: get subject average of time variables

Description

A function for calcualting the average timing of variables (in this case the M10 and L5). Find the average timing mu that min( sum ( min( (tind_i - mu)^2, (1440 + mu - tind_i )^2 )))

Usage

get_mean_sd_hour(tind, unit2minute = 60, out = c("mean", "sd"))

Value

mean and sd of the input timing

Arguments

tind

numeric A vector of times which we want to get an average/sd for. The first two columns have to be ID and Day.

unit2minute

numeric The ratio of the unit of time and minute. For example, the input unit is hour, the unit2minute = 60.

out

character Specify get the mean or sd of the time variables. Default=c("mean","sd") when both mean and sd are calculated.

Examples

Run this code
x=c(1,1,1,23,23,23) 
get_mean_sd_hour(tind=x,  unit2minute=60) 
x=12+c(1,1,1,23,23,23) 
get_mean_sd_hour(tind=x,  unit2minute=60)   
x=c(1:100/5, 20+4:50/200) 
get_mean_sd_hour(tind=x,  unit2minute=60)

Run the code above in your browser using DataLab