Content
We will have a very awesome interesting question very soon.
We will have a very awesome interesting question very soon.
All the techniques… specifically
Still deciding on which data to use. Below is sample data which includes:
#read csv
data = read.csv("data/alxsmith_fishermen.csv")
#output summary
summary(data)
## fisherman age restime height
## Min. :0.0000 Min. :16.00 Min. : 0.000 Min. :154.0
## 1st Qu.:0.0000 1st Qu.:28.00 1st Qu.: 2.000 1st Qu.:170.0
## Median :1.0000 Median :32.00 Median : 2.000 Median :175.0
## Mean :0.7407 Mean :33.76 Mean : 4.593 Mean :174.4
## 3rd Qu.:1.0000 3rd Qu.:37.50 3rd Qu.: 6.000 3rd Qu.:180.0
## Max. :1.0000 Max. :58.00 Max. :25.000 Max. :195.0
## weight fishmlwk fishpart MeHg
## Min. :59.00 Min. : 0.000 Min. :0.000 Min. : 0.019
## 1st Qu.:68.50 1st Qu.: 2.000 1st Qu.:1.000 1st Qu.: 1.857
## Median :73.00 Median : 7.000 Median :2.000 Median : 2.957
## Mean :73.16 Mean : 6.526 Mean :1.711 Mean : 3.644
## 3rd Qu.:77.00 3rd Qu.: 7.000 3rd Qu.:2.000 3rd Qu.: 4.539
## Max. :92.00 Max. :21.000 Max. :3.000 Max. :17.214
## TotHg
## Min. : 0.025
## 1st Qu.: 1.904
## Median : 3.006
## Mean : 3.775
## 3rd Qu.: 4.688
## Max. :17.788
Here’s a sample plot:
#getwd()
#setwd('students')
list.files()
## [1] "adam1993.html" "adam1993.Rmd"
## [3] "alxsmith_files" "alxsmith.html"
## [5] "alxsmith.Rmd" "bbest.html"
## [7] "bbest.Rmd" "caio-faro.html"
## [9] "caio-faro.Rmd" "daalbu.html"
## [11] "daalbu.Rmd" "data"
## [13] "faundez.html" "faundez.Rmd"
## [15] "gmcdonald-sfg.html" "gmcdonald-sfg.Rmd"
## [17] "images" "index.md"
## [19] "jcvdav.html" "jcvdav.Rmd"
## [21] "jebone.html" "jebone.Rmd"
## [23] "jepa.html" "jepa.Rmd"
## [25] "jkidson.html" "jkidson.Rmd"
## [27] "juanmayorgahenao.html" "juanmayorgahenao.Rmd"
## [29] "julianaherrera.html" "julianaherrera.Rmd"
## [31] "julimatos.html" "julimatos.Rmd"
## [33] "jupa1089.html" "jupa1089.Rmd"
## [35] "knboysen.html" "knboysen.Rmd"
## [37] "maierucsb.html" "maierucsb.Rmd"
## [39] "naomitague.html" "naomitague.Rmd"
## [41] "nhartline.html" "nhartline.Rmd"
## [43] "pricessnapper.csv" "sgriff.html"
## [45] "sgriff.Rmd" "smccutcheon.html"
## [47] "smccutcheon.Rmd" "snappermap.png"
## [49] "sparrow925.html" "sparrow925.Rmd"
## [51] "wag7.html" "wag7.Rmd"
## [53] "zebos1.html" "zebos1.Rmd"
list.files(pattern=glob2rx('*.png'))
## [1] "snappermap.png"
file.exists('test.png')
## [1] FALSE
d = read.csv('../data/r-ecology/species.csv')
d
## species_id genus species taxa
## 1 AB Amphispiza bilineata Bird
## 2 AH Ammospermophilus harrisi Rodent
## 3 AS Ammodramus savannarum Bird
## 4 BA Baiomys taylori Rodent
## 5 CB Campylorhynchus brunneicapillus Bird
## 6 CM Calamospiza melanocorys Bird
## 7 CQ Callipepla squamata Bird
## 8 CS Crotalus scutalatus Reptile
## 9 CT Cnemidophorus tigris Reptile
## 10 CU Cnemidophorus uniparens Reptile
## 11 CV Crotalus viridis Reptile
## 12 DM Dipodomys merriami Rodent
## 13 DO Dipodomys ordii Rodent
## 14 DS Dipodomys spectabilis Rodent
## 15 DX Dipodomys sp. Rodent
## 16 EO Eumeces obsoletus Reptile
## 17 GS Gambelia silus Reptile
## 18 NL Neotoma albigula Rodent
## 19 NX Neotoma sp. Rodent
## 20 OL Onychomys leucogaster Rodent
## 21 OT Onychomys torridus Rodent
## 22 OX Onychomys sp. Rodent
## 23 PB Chaetodipus baileyi Rodent
## 24 PC Pipilo chlorurus Bird
## 25 PE Peromyscus eremicus Rodent
## 26 PF Perognathus flavus Rodent
## 27 PG Pooecetes gramineus Bird
## 28 PH Perognathus hispidus Rodent
## 29 PI Chaetodipus intermedius Rodent
## 30 PL Peromyscus leucopus Rodent
## 31 PM Peromyscus maniculatus Rodent
## 32 PP Chaetodipus penicillatus Rodent
## 33 PU Pipilo fuscus Bird
## 34 PX Chaetodipus sp. Rodent
## 35 RF Reithrodontomys fulvescens Rodent
## 36 RM Reithrodontomys megalotis Rodent
## 37 RO Reithrodontomys montanus Rodent
## 38 RX Reithrodontomys sp. Rodent
## 39 SA Sylvilagus audubonii Rabbit
## 40 SB Spizella breweri Bird
## 41 SC Sceloporus clarki Reptile
## 42 SF Sigmodon fulviventer Rodent
## 43 SH Sigmodon hispidus Rodent
## 44 SO Sigmodon ochrognathus Rodent
## 45 SS Spermophilus spilosoma Rodent
## 46 ST Spermophilus tereticaudus Rodent
## 47 SU Sceloporus undulatus Reptile
## 48 SX Sigmodon sp. Rodent
## 49 UL Lizard sp. Reptile
## 50 UP Pipilo sp. Bird
## 51 UR Rodent sp. Rodent
## 52 US Sparrow sp. Bird
## 53 ZL Zonotrichia leucophrys Bird
## 54 ZM Zenaida macroura Bird
head(d)
## species_id genus species taxa
## 1 AB Amphispiza bilineata Bird
## 2 AH Ammospermophilus harrisi Rodent
## 3 AS Ammodramus savannarum Bird
## 4 BA Baiomys taylori Rodent
## 5 CB Campylorhynchus brunneicapillus Bird
## 6 CM Calamospiza melanocorys Bird
summary(d)
## species_id genus species taxa
## AB : 1 Chaetodipus : 4 sp. :10 Bird :13
## AH : 1 Dipodomys : 4 hispidus : 2 Rabbit : 1
## AS : 1 Reithrodontomys: 4 albigula : 1 Reptile: 9
## BA : 1 Sigmodon : 4 audubonii: 1 Rodent :31
## CB : 1 Onychomys : 3 baileyi : 1
## CM : 1 Peromyscus : 3 bilineata: 1
## (Other):48 (Other) :32 (Other) :38
class(d$species_id)
## [1] "factor"
#factor
library(readr)
d = read_csv('../data/r-ecology/species.csv')
d
## species_id genus species taxa
## 1 AB Amphispiza bilineata Bird
## 2 AH Ammospermophilus harrisi Rodent
## 3 AS Ammodramus savannarum Bird
## 4 BA Baiomys taylori Rodent
## 5 CB Campylorhynchus brunneicapillus Bird
## 6 CM Calamospiza melanocorys Bird
## 7 CQ Callipepla squamata Bird
## 8 CS Crotalus scutalatus Reptile
## 9 CT Cnemidophorus tigris Reptile
## 10 CU Cnemidophorus uniparens Reptile
## 11 CV Crotalus viridis Reptile
## 12 DM Dipodomys merriami Rodent
## 13 DO Dipodomys ordii Rodent
## 14 DS Dipodomys spectabilis Rodent
## 15 DX Dipodomys sp. Rodent
## 16 EO Eumeces obsoletus Reptile
## 17 GS Gambelia silus Reptile
## 18 NL Neotoma albigula Rodent
## 19 NX Neotoma sp. Rodent
## 20 OL Onychomys leucogaster Rodent
## 21 OT Onychomys torridus Rodent
## 22 OX Onychomys sp. Rodent
## 23 PB Chaetodipus baileyi Rodent
## 24 PC Pipilo chlorurus Bird
## 25 PE Peromyscus eremicus Rodent
## 26 PF Perognathus flavus Rodent
## 27 PG Pooecetes gramineus Bird
## 28 PH Perognathus hispidus Rodent
## 29 PI Chaetodipus intermedius Rodent
## 30 PL Peromyscus leucopus Rodent
## 31 PM Peromyscus maniculatus Rodent
## 32 PP Chaetodipus penicillatus Rodent
## 33 PU Pipilo fuscus Bird
## 34 PX Chaetodipus sp. Rodent
## 35 RF Reithrodontomys fulvescens Rodent
## 36 RM Reithrodontomys megalotis Rodent
## 37 RO Reithrodontomys montanus Rodent
## 38 RX Reithrodontomys sp. Rodent
## 39 SA Sylvilagus audubonii Rabbit
## 40 SB Spizella breweri Bird
## 41 SC Sceloporus clarki Reptile
## 42 SF Sigmodon fulviventer Rodent
## 43 SH Sigmodon hispidus Rodent
## 44 SO Sigmodon ochrognathus Rodent
## 45 SS Spermophilus spilosoma Rodent
## 46 ST Spermophilus tereticaudus Rodent
## 47 SU Sceloporus undulatus Reptile
## 48 SX Sigmodon sp. Rodent
## 49 UL Lizard sp. Reptile
## 50 UP Pipilo sp. Bird
## 51 UR Rodent sp. Rodent
## 52 US Sparrow sp. Bird
## 53 ZL Zonotrichia leucophrys Bird
## 54 ZM Zenaida macroura Bird
head(d)
## species_id genus species taxa
## 1 AB Amphispiza bilineata Bird
## 2 AH Ammospermophilus harrisi Rodent
## 3 AS Ammodramus savannarum Bird
## 4 BA Baiomys taylori Rodent
## 5 CB Campylorhynchus brunneicapillus Bird
## 6 CM Calamospiza melanocorys Bird
summary(d)
## species_id genus species
## Length:54 Length:54 Length:54
## Class :character Class :character Class :character
## Mode :character Mode :character Mode :character
## taxa
## Length:54
## Class :character
## Mode :character
class(d$species_id)
## [1] "character"
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
#read in csv
surveys=read_csv('../data/r-ecology/surveys.csv')
#dplyr elegance
surveys %T>% # note tee operator %T>% for glimpse
glimpse() %>% # view data
select(species_id, year) %>% # limit columns
filter(species_id == 'NL') %>% # limit rows
group_by(year) %>% # get count by first grouping
summarize(n = n()) %>% # then summarize
write_csv('data/surveys_bbest.csv') # write out csv
## Observations: 35,549
## Variables: 9
## $ record_id (int) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,...
## $ month (int) 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7...
## $ day (int) 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16...
## $ year (int) 1977, 1977, 1977, 1977, 1977, 1977, 1977, 1977...
## $ plot_id (int) 2, 3, 2, 7, 3, 1, 2, 1, 1, 6, 5, 7, 3, 8, 6, 4...
## $ species_id (chr) "NL", "NL", "DM", "DM", "DM", "PF", "PE", "DM"...
## $ sex (chr) "M", "M", "F", "M", "M", "M", "F", "M", "F", "...
## $ hindfoot_length (int) 32, 33, 37, 36, 35, 14, NA, 37, 34, 20, 53, 38...
## $ weight (int) NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...