Content
I work with the Fish Forever initiative (Fish Forever), a partnership between the Sustainable Fisheries Group at UCSB, Rare, and Environmental Defense Fund, aimed at improving management of small-scale fisheries in the developing tropics through the use of TURF-reserves.

One of the most critical challenges we face is assessing and managing fisheris in the data- and resource-limited situations where we work. To address this, we are using data-limited assessment techniques to creatively work with the data that we do have. However, no single technique is perfect, so we are therefore using multiple techniques to examine each fishery so that we can have a more complete understanding of how the fishery is performing. I therefore have two main research questions:
- How can multiple data-limited assessment techniques, which might each give conflicting indications for how a fishery is doing, be interpreted and synthesized to make better management decisions for a fishery?
- How does including uncertainty, both in measurement error and life history information error, affect the interpretation and synthesis of multiple indicators?
Data Wrangling
Working in R and the terminal
# present working directory
getwd()
# change working directory
setwd('.')
# list files
list.files()
# list files that end in '.jpg'
list.files(pattern=glob2rx('*.jpg'))
# file exists
file.exists('test.png')
setwd('students')
Installing packages
# Run this chunk only once in your Console
# Do not evaluate when knitting Rmarkdown
# list of packages
pkgs = c(
'readr', # read csv
'readxl', # read xls
'dplyr', # data frame manipulation
'tidyr', # data tidying
'nycflights13', # test dataset of NYC flights for 2013
'gapminder') # test dataset of life expectancy and popultion
# install packages if not found
for (p in pkgs){
if (!require(p, character.only=T)){
install.packages(p)
}
}
Reading in csvs with utils::read.csv
d = read.csv('../data/r-ecology/species.csv')
d
head(d)
summary(d)
Reading in csvs with readr::read_csv
library(readr)
d = read_csv('../data/r-ecology/species.csv')
d
head(d)
summary(d)
Formatting tables with dplry::tbl_df
library(readr)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
d = read_csv('../data/r-ecology/surveys.csv') %>%
tbl_df() %>%
select(species_id,year) %>%
#filter(species_id == "NL") %>%
group_by(species_id,year) %>%
summarize(count = n())
d
## Source: local data frame [535 x 3]
## Groups: species_id [?]
##
## species_id year count
## (chr) (int) (int)
## 1 AB 1980 5
## 2 AB 1981 7
## 3 AB 1982 34
## 4 AB 1983 41
## 5 AB 1984 12
## 6 AB 1985 14
## 7 AB 1986 5
## 8 AB 1987 35
## 9 AB 1988 39
## 10 AB 1989 31
## .. ... ... ...
head(d)
## Source: local data frame [6 x 3]
## Groups: species_id [1]
##
## species_id year count
## (chr) (int) (int)
## 1 AB 1980 5
## 2 AB 1981 7
## 3 AB 1982 34
## 4 AB 1983 41
## 5 AB 1984 12
## 6 AB 1985 14
summary(d)
## species_id year count
## Length:535 Min. :1977 Min. : 1.00
## Class :character 1st Qu.:1984 1st Qu.: 3.00
## Mode :character Median :1990 Median : 19.00
## Mean :1990 Mean : 66.45
## 3rd Qu.:1996 3rd Qu.: 65.00
## Max. :2002 Max. :892.00
glimpse(d)
## Observations: 535
## Variables: 3
## $ species_id (chr) "AB", "AB", "AB", "AB", "AB", "AB", "AB", "AB", "AB...
## $ year (int) 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 198...
## $ count (int) 5, 7, 34, 41, 12, 14, 5, 35, 39, 31, 27, 15, 10, 9,...