8 Basic Fisheries Statistics
8.1 Calculating Landings
One of the first analyses you may be interested in is calculating annual landings in the fishery. To calculate annual landings, take your landings_data
data frame, add a column for weight of individual fish in kilograms by using the mutate
function, group the data by year by using the group_by
function, and then summarize the data for each year by summing the total weight of all fish caught in each year using the summarize
and sum
functions.
# Start with the landings data frame
annual_landings <- landings_data %>%
# Add colomn for kilograms by dividing gram column by 1000
mutate(Weight_kg = Weight_g / 1000) %>%
# Group the data by year
group_by(Year) %>%
# Next, summarize the total annual landings per year
summarize(Annual_Landings_kg = sum(Weight_kg,na.rm=TRUE))
## Display a table of the annual landings data
annual_landings
## # A tibble: 9 x 2
## Year Annual_Landings_kg
## <int> <dbl>
## 1 2003 310.40914
## 2 2004 565.30807
## 3 2005 163.24191
## 4 2006 37.11914
## 5 2010 131.84178
## 6 2011 156.77825
## 7 2012 101.53198
## 8 2013 579.52008
## 9 2014 1193.75519
Note the use of na.rm = TRUE
in the code above. This is an important argument of many R functions (sum()
in this case) and it tells R what to do with NA
values in your data. Here, we are telling R to first remove NA
values before calculating the sum of the Weight_kg
variable. By default, many functions will return NA
if any value is NA
, which is often not desirable.
You may be interested in looking at landings across different gear types. Here, we now group the data frame by both the year and the gear type in order to summarize the total landings by year and by gear.
# Start with the landings data frame
annual_gear_landings <- landings_data %>%
# Add colomn for kilograms by dividing gram column by 1000
mutate(Weight_kg = Weight_g / 1000) %>%
# Group the data by year and gear type
group_by(Year,Gear) %>%
# Next, summarize the total annual landings per year and gear type
summarize(Annual_Landings_kg = sum(Weight_kg,na.rm=TRUE))
## Display a table of the annual landings data by gear type
annual_gear_landings
## # A tibble: 39 x 3
## # Groups: Year [?]
## Year Gear Annual_Landings_kg
## <int> <chr> <dbl>
## 1 2003 gillnet 13.413401
## 2 2003 handline 2.874861
## 3 2003 muroami 247.879049
## 4 2003 trap 46.241825
## 5 2004 gillnet 4.189301
## 6 2004 handline 57.705893
## 7 2004 muroami 370.866460
## 8 2004 speargun 9.476406
## 9 2004 trap 118.683464
## 10 2004 trolling 4.386547
## # ... with 29 more rows
8.2 Calculating Catch-per-Unit-Effort (CPUE)
You may also be interested in calculating catch-per-unit-effort (CPUE). CPUE is calculated by dividing the catch of each fishing trip by the number of hours fished during that trip. This gives CPUE in units of kilograms per hour. The median for every year is then calculated in order to remove outliers - some fishers are much more efficient than others.
# Start with the landings data frame
cpue_data <- landings_data %>%
# Add colomn for kilograms by dividing gram column by 1000
mutate(Weight_kg = Weight_g / 1000) %>%
# Group by year and Trip ID so that you can calculate CPUE for every trip in every year
group_by(Year,Trip_ID) %>%
# For each year and trip ID, calculate the CPUE for each trip by dividing the sum of the catch, converted from grams to kilograms, by the trip by the number of fishing hours
summarize(Trip_CPUE = sum(Weight_kg) / mean(Effort_Hours)) %>%
# Next, just group by year so we can calculate median CPUE for each year across all trips in the year
group_by(Year) %>%
# Calculate median CPUE for each year
summarize(Median_CPUE_kg_hour = median(Trip_CPUE))
# Display a table of the CPUE data
cpue_data
## # A tibble: 9 x 2
## Year Median_CPUE_kg_hour
## <int> <dbl>
## 1 2003 0.31834277
## 2 2004 0.26233292
## 3 2005 0.40145105
## 4 2006 0.44029501
## 5 2010 0.01742840
## 6 2011 0.03123217
## 7 2012 0.03123217
## 8 2013 0.19638408
## 9 2014 0.88216281
8.3 Calculating Percent Mature
You may also wish to analyze your length data. One analysis would be to determine the percentage of mature fish in the catch in every year of the data frame. First let’s define m95
, the length at which 95% of fish are mature. For Caesio cuning, we know this is 15.9cm. Next, let’s add a column to the data frame using the mutate
function that represents whether each fish is mature or not (represented by a TRUE
or FALSE
), group the data frame by year, and then summarize for each year the percentage of mature fish out of the total number of sampled fish.
# Define m95, the length at which 95% of fish are mature
m95 = 15.9
# Start with the landings data frame
landings_data %>%
# Add a column to the data that indicates whether each length measurement is from a mature or immature fish. If it's mature, this value should be TRUE; if immature, FALSE.
mutate(Mature = Length_cm > m95) %>%
# Group by year so we can see the percent mature for every year
group_by(Year) %>%
# The percentage mature is equal to the number of mature fish divided by the total number of fish and multiplied by 100
summarize(Percent_Mature = sum(Mature) / n() * 100)
## # A tibble: 9 x 2
## Year Percent_Mature
## <int> <dbl>
## 1 2003 98.56916
## 2 2004 98.62188
## 3 2005 97.73371
## 4 2006 100.00000
## 5 2010 91.80556
## 6 2011 99.77629
## 7 2012 99.65398
## 8 2013 99.46164
## 9 2014 99.55665
Over 90% of the fish are mature throughout the time series, which is a great sign!
8.4 Helpful Resources
- Data Wrangling with dplyr and tidyr Cheat Sheet is a very helpful resource for learning how to “wrangle” (manipulate) data in R