-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiff_script.R
More file actions
39 lines (26 loc) · 960 Bytes
/
diff_script.R
File metadata and controls
39 lines (26 loc) · 960 Bytes
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
# Script to perform differenced values
# Read data ---------------------------------------------------------------
data <- read.csv("log_data.csv")
# Subsetting --------------------------------------------------------------
data <- data[,c(-1,-2,-5,-7,-8)]
cat("No of missing values : ",sum(is.na(data)),"\n")
cat("No. of variables : ",ncol(data),"\n")
cat("Training cases : ",nrow(data),"\n")
# Indexing ----------------------------------------------------------------
data <- cbind(data,NA)
colnames(data)[4] <- "Diff"
data[1:nrow(data),]
for(i in 1:nrow(data)){
cat("Step no. :",i,"\n")
if(grepl("3",data$Code[i])){
cat("3 found \t")
temp <- data$Time[i]
}
if(Label[i] == "Response"){
cat("Response found", i,"\t")
data[i,4] <- data$Time[i] - temp
}
}
# Update data -------------------------------------------------------------
data[1:nrow(data),]
write.csv(data,"aut_diff.csv")