-
Notifications
You must be signed in to change notification settings - Fork 0
/
travel time.R
75 lines (46 loc) · 1.93 KB
/
travel time.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
70
71
72
73
74
75
####################################### Estimating travel time from Mc to IHA ##############
IHAtag <- as.data.frame(Complete_Tag_History_MC_IHA)
n <- nrow(IHAtag)
uniquetag <- length(unique(IHAtag$`Tag Code`)) # number of unique fish
count <- 0
c <- rep(NA,(n-2*uniquetag))
for(i in 1:(n)){
if(IHAtag$`Event Site Name`[i]=="MC1 - McNary Oregon Shore Ladder" || IHAtag$`Event Site Name`[i]=="MC2 - McNary Washington Shore Ladder"){
IHAtag$`Event Site Name`[i] <- "MC"
}
}
# MC1 and MC2 are both at the same dam.
for(i in 1:(n-1)){
if(IHAtag$`Tag Code`[i]==IHAtag$`Tag Code`[(i+1)]){
if(IHAtag$`Event Site Name`[i] == IHAtag$`Event Site Name`[i+1]){
count <- count +1
c[count] <- i
}
}
}
# looking at all the fish that were detected multiple times at the same site
IHAtag <- IHAtag[-c,]
# removing all those detections.
write.csv(IHAtag,'C:\\Users\\mariakur\\Documents\\Spring 2019\\QERM 514\\project\\traveltimeMCtoIHA.csv')
#########################################################################################################################
#doing the same thing for Priest Rapids dam.
IHAtag <- as.data.frame(PRAtag)
n <- nrow(IHAtag)
uniquetag <- length(unique(IHAtag$`Tag Code`))
count <- 0
c <- rep(NA,(n-2*uniquetag))
for(i in 1:(n)){
if(IHAtag$`Event Site Name`[i]=="MC1 - McNary Oregon Shore Ladder" || IHAtag$`Event Site Name`[i]=="MC2 - McNary Washington Shore Ladder"){
IHAtag$`Event Site Name`[i] <- "MC"
}
}
for(i in 1:(n-1)){
if(IHAtag$`Tag Code`[i]==IHAtag$`Tag Code`[(i+1)]){
if(IHAtag$`Event Site Name`[i] == IHAtag$`Event Site Name`[i+1]){
count <- count +1
c[count] <- i
}
}
}
IHAtag <- IHAtag[-c,]
write.csv(IHAtag,'C:\\Users\\mariakur\\Documents\\Spring 2019\\QERM 514\\project\\traveltimeMCtoPRA.csv')