Skip to content

Commit db9c3f2

Browse files
committed
working on master table
1 parent fc94d7e commit db9c3f2

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed

R/funs.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ interp_fun <- function(y, fs, ...){
44
out_t <- seq(from=floor(min(y$V1)), to=round(max(y$V1)), by= 1/fs)
55
df_v1 <- approx(x=y$V1, y=y$V2, xout=out_t, method='linear')
66
df_v2 <- data.frame(df_v1)
7-
colnames(df_v2) <- c("t", "y")
7+
colnames(df_v2) <- c("t", "V2")
88
fin_df <- na.omit(df_v2)
99

1010
return(as.data.frame(fin_df))

R/mastertable_generation.R

+32-9
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,33 @@ MASTER_FILE <- "~/Documents/snail_back_pack/experiments/snail_temperature_experi
55

66

77

8+
makedt_for_animal <- function(subdt, fs=5){
89

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)
919

1020

21+
fin_dt
22+
23+
}
1124

1225

13-
14-
15-
16-
17-
makedt_for_animal <- function(subdt){
26+
makedt_for_animal_interp <- function(subdt){
1827

1928
heart_dt <- fread(subdt$heart_file)
2029
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)
2535
}
2636

2737

@@ -35,6 +45,19 @@ master_table_v2[, temp_file:= paste(RESULT_DIR,gsub("\\s", "", temp_file),sep="/
3545
master_table_v2 <- master_table_v2[ID<13, ]
3646
setkey(master_table_v2,ID)
3747

48+
3849
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)
3955

4056
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

Comments
 (0)