-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleanthree.R
69 lines (44 loc) · 1.72 KB
/
cleanthree.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
cleanthree <- function (input){
# print(input)
# input <- rngtrap[3]
input <- input[3]
rngsplit3<-unlist(strsplit(input, "\" ", fixed = TRUE))
keeps <- c(".")
rngrange3 <- gsub(paste0(".*?($|'|", paste(paste0("\\",
keeps), collapse = "|"), "|[^[:punct:]]).*?"), "\\1", rngsplit3[2])
rngrangesplit3 <- gsub('BP','',rngrange3)
# print(rngrangesplit3)
rngrangesplit32 <- strsplit(gsub(paste0("([[:alnum:]]{", # Apply strsplit function
6,
"})"),
"\\1 ",
rngrangesplit3),
" ")[[1]]
# print(rngrangesplit32)
rngrangesplit32_num <- as.numeric(rngrangesplit32)
rngrangesplit32_num_noNA<-rngrangesplit32_num[!is.na(rngrangesplit32_num)]
time.s32 <- rngrangesplit32_num_noNA[1]
time.e32 <- rngrangesplit32_num_noNA[3]
# print(time.e32)
accuracy <- 0
# Define value
x1 <- 5000
# Define lower bound
left1 <- time.e32
# Define upper bound
right1 <- time.s32
# Apply between function
range32 <- between(x1, left1, right1)
# print(range32)
if (range32 == "TRUE")
{
accuracy <- accuracy + 1
}
margin <- time.s32 - time.e32
distancefromstart <- 0
if (accuracy == 0){
distancefromstart <- min(c(abs(5000 - rngrangesplit32_num_noNA[1]),abs(5000 - rngrangesplit32_num_noNA[3])))
}
new_row <- c(margin, accuracy, distancefromstart)
trap_df[nrow(trap_df) + 1, ] <<- new_row
}