R/create_test_sleeplog_csv.R

Defines functions create_test_sleeplog_csv

Documented in create_test_sleeplog_csv

create_test_sleeplog_csv = function(Nnights=7,storagelocation=c()) {
  # function to create a test sleeplog file needed for testing GGIR
  # Nnights is the number of nights the sleeplog has
  if (length(storagelocation) == 0) storagelocation = getwd()
  if (Nnights == 0) Nnights = 1
  Nnights= 7
  sleeplog = as.data.frame(t(c("123",rep(c("23:00:00","07:00:00"),Nnights))))
  sleeplog[,4:5]=c("03:00:00","13:00:00") # let's add one night where the person slept untill the afternoon
  colnames(sleeplog) = c("id",rep(c("onset","wakeup"),Nnights))
  write.table(sleeplog,file=paste0(storagelocation,"/testsleeplogfile.csv"),row.names = FALSE,col.names = TRUE,sep=",",fileEncoding="UTF-8")
}
PeteJWatson/ggircal documentation built on Nov. 24, 2021, 11:14 a.m.