-
Notifications
You must be signed in to change notification settings - Fork 0
/
SleepScan.R
52 lines (33 loc) · 952 Bytes
/
SleepScan.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Load packages --------------------
library(tidyverse)
library(devtools)
library(usethis)
#funcao que retorna o log
logName <- function(logFile) {
read.table (
logFile,
header = T,
sep = ";",
stringsAsFactors = FALSE,
as.is = TRUE )
}
#funcao que seleciona os dias com base no state selecionado (0-2)
sleep_select <- function(x) {
if (x < 3 && x >= 0) {
filter(logTeste,logTeste$STATE == x)
}
}
#variavel que recebe o log
logTeste <- logName(file.choose())
#transforma a coluna TIME do log para caracter
logTeste$TIME <- as.character(logTeste$TIME)
#funcao que tranforma HH::MM:SS format em decimal
dat<-c(logTeste$TIME)
logTeste$TIME <- sapply(strsplit(dat,":"),
function(x) {
x <- as.numeric(x)
x[1]+x[2]/60+x[3]/3600
}
)
#variavel que recebe os dados com base no state
sleep_Scan <- sleep_select(1)