@@ -5,23 +5,33 @@ MASTER_FILE <- "~/Documents/snail_back_pack/experiments/snail_temperature_experi
5
5
6
6
7
7
8
+ makedt_for_animal <- function (subdt , fs = 5 ){
8
9
10
+ heart_dt <- fread(subdt $ heart_file )
11
+ temp_dt <- fread(subdt $ temp_file )
12
+
13
+ out_t <- seq(from = floor(min(heart_dt $ V1 )), to = round(max(heart_dt $ V1 )), by = 1 / fs )
14
+ li_heart <- approx(x = heart_dt $ V1 , y = heart_dt $ V2 , xout = out_t , method = ' linear' )
15
+ li_temp <- approx(x = temp_dt $ V1 , y = temp_dt $ V2 , xout = out_t , method = ' linear' )
16
+ # map here
17
+ out_dt <- data.table(t = li_heart $ x , l = li_heart $ y , temp = li_temp $ y )
18
+ fin_dt <- na.omit(out_dt )
9
19
10
20
21
+ fin_dt
22
+
23
+ }
11
24
12
25
13
-
14
-
15
-
16
-
17
- makedt_for_animal <- function (subdt ){
26
+ makedt_for_animal_interp <- function (subdt ){
18
27
19
28
heart_dt <- fread(subdt $ heart_file )
20
29
temp_dt <- fread(subdt $ temp_file )
21
- # #interpolation goes here
22
-
23
- heart_dt
24
-
30
+
31
+ interp_heart <- interp_fun(heart_dt , fs = 5 )
32
+ interp_temp <- interp_fun(temp_dt , fs = 5 )
33
+ li <- merge(interp_temp , interp_heart , by = " t" )
34
+ return (li )
25
35
}
26
36
27
37
@@ -35,6 +45,19 @@ master_table_v2[, temp_file:= paste(RESULT_DIR,gsub("\\s", "", temp_file),sep="/
35
45
master_table_v2 <- master_table_v2 [ID < 13 , ]
36
46
setkey(master_table_v2 ,ID )
37
47
48
+
38
49
test <- master_table_v2 [,makedt_for_animal(.SD ),by = ID ]
50
+ test <- master_table_v2 [,makedt_for_animal(.SD ),by = c(" ID" ," t_m" )]
51
+
52
+
53
+ li <- list (test1 , test2 , test3 )
54
+ test <- rbindlist(li , fill = T )
39
55
40
56
master_table_v2 [test ]
57
+
58
+
59
+
60
+
61
+
62
+
63
+ # Notes: combine function makedt fun into one, arguments into list/table/etc.
0 commit comments