Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MJacobs1985/a018619018b62d396cb7db268712294e to your computer and use it in GitHub Desktop.
Save MJacobs1985/a018619018b62d396cb7db268712294e to your computer and use it in GitHub Desktop.
dataset <- read_excel(".xlsx", col_types = c("numeric", "numeric", "date",
"numeric", "numeric", "numeric","numeric", "numeric", "numeric",
"numeric", "numeric", "numeric", "numeric", "numeric", "numeric",
"numeric", "numeric", "numeric", "numeric", "numeric", "numeric",
"numeric", "numeric", "numeric", "numeric", "numeric", "numeric",
"numeric", "numeric"))
str(dataset)
skim(dataset)
attach(dataset)
dataset$ID<-as.factor(dataset$ID)
## Now, for the time-series analysis, the data is not really helpfull.
## What I need is the deviation of each timeline since start per ID to see what is happening after they start measuring */
dataset <- dataset%>%
arrange(ID, Tijdstip) %>%
group_by(ID) %>%
mutate(ElapsedTime = Tijdstip - Tijdstip[1L]) %>%
ungroup()
## Lets add columns based on what dataset was saying
dataset$PO2art_bin<-as.factor(ifelse(between(dataset$PO2art,120,150),0,1))
dataset$DO2i_methode1_gen_bin<-as.factor(ifelse(dataset$DO2i_methode1>272,0,1))
dataset$DO2i_methode1_cath_bin<-as.factor(ifelse(dataset$DO2i_methode1>310,0,1))
dataset$DO2i_methode2_gen_bin<-as.factor(ifelse(dataset$DO2i_methode2>272,0,1))
dataset$DO2i_methode2_cath_bin<-as.factor(ifelse(dataset$DO2i_methode2>310,0,1))
dataset$RQ_methode1_bin<-as.factor(ifelse(dataset$RQ_methode1>0.9,0,1))
dataset$RQ_methode2_bin<-as.factor(ifelse(dataset$RQ_methode2>0.9,0,1))
dataset$DO2iVCO2i_1_bin<-as.factor(ifelse(dataset$DO2iVCO2i_methode1<5,0,1))
dataset$DO2iVCO2i_2_bin<-as.factor(ifelse(dataset$DO2iVCO2i_methode2<5,0,1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment