-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_dive_depth_data.R
53 lines (42 loc) · 2.98 KB
/
add_dive_depth_data.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
#load dive data file
divedf<-read.csv("Depth list.csv")
divedf<-divedf[1:57,]
#Classify SURFACE category from more detailed foraging modes
divedf$feedmode2<-NA #reduce ecological groups
divedf$feedmode2<-ifelse(divedf$Categories_feeding=="Dipping", "Surface", divedf$feedmode2)
divedf$feedmode2<-ifelse(divedf$Categories_feeding=="Surface seizing - plunge diving?", "Surface", divedf$feedmode2)
divedf$feedmode2<-ifelse(divedf$Categories_feeding=="Dipping - Surface plunging? ", "Surface", divedf$feedmode2)
divedf$feedmode2<-ifelse(divedf$Categories_feeding=="Pattering", "Surface", divedf$feedmode2)
divedf$feedmode2<-ifelse(divedf$Categories_feeding=="Surface seizing", "Surface", divedf$feedmode2)
divedf$feedmode2<-ifelse(divedf$Categories_feeding=="Surface diving", "Surface", divedf$feedmode2)
#Classify UNDERWATER PURSUIT category from more detailed foraging modes
divedf$feedmode2<-ifelse(divedf$Categories_feeding=="Pursuit diving", "Underwater pursuit", divedf$feedmode2)
divedf$feedmode2<-ifelse(divedf$Categories_feeding=="Shallow swimming", "Underwater pursuit", divedf$feedmode2)
#Classify PLUNGING (surface & pursuit plunging) category from more detailed foraging modes
divedf$feedmode2<-ifelse(divedf$Categories_feeding=="Surface plunging", "Plunging", divedf$feedmode2)
divedf$feedmode2<-ifelse(divedf$Categories_feeding=="Pursuit plunging", "Plunging", divedf$feedmode2)
divedf$feedmode2<-ifelse(divedf$Categories_feeding=="Surface plunging", "Plunging", divedf$feedmode2)
divedf$feedmode2<-ifelse(divedf$Categories_feeding=="Surface plunging", "Plunging", divedf$feedmode2)
#Match the dive dataframe to the main dataframe by species name
match(divedf$IOC_2020_Binomial,avgdf$Binomial) #a list of the rows in the main df.
#add dive data to main df
avgdf$maxdd<-NA
avgdf$maxdd[match(divedf$IOC_2020_Binomial,avgdf$Binomial)]<-divedf$Max_dive_depth
avgdf$divescore<-NA
avgdf$divescore[match(divedf$IOC_2020_Binomial,avgdf$Binomial)]<-divedf$Dive.score
avgdf$catfeeding<-NA
avgdf$catfeeding[match(divedf$IOC_2020_Binomial,avgdf$Binomial)]<-as.character(divedf$Categories_feeding)
avgdf$catfeeding2<-NA
avgdf$catfeeding2[match(divedf$IOC_2020_Binomial,avgdf$Binomial)]<-as.character(divedf$feedmode2)
avgdf$Avg_max_depth<-NA
avgdf$Avg_max_depth[match(divedf$IOC_2020_Binomial,avgdf$Binomial)]<-as.character(divedf$Avg_max_depth)
avgdf$Max_duration..s.<-NA
avgdf$Max_duration..s.[match(divedf$IOC_2020_Binomial,avgdf$Binomial)]<-as.character(divedf$Max_duration..s.)
avgdf$Avg_max_dur<-NA
avgdf$Avg_max_dur[match(divedf$IOC_2020_Binomial,avgdf$Binomial)]<-as.character(divedf$Avg_max_dur)
avgdf$Method<-NA
avgdf$Method[match(divedf$IOC_2020_Binomial,avgdf$Binomial)]<-as.character(divedf$Method)
avgdf$Reference_depth<-NA
avgdf$Reference_depth[match(divedf$IOC_2020_Binomial,avgdf$Binomial)]<-as.character(divedf$Reference_depth)
avgdf$Reference_duration<-NA
avgdf$Reference_duration[match(divedf$IOC_2020_Binomial,avgdf$Binomial)]<-as.character(divedf$Reference_duration)