Visualizing Age-Length Keys — More

April 15, 2014
By

(This article was first published on fishR » R, and kindly contributed to R-bloggers)

I recently posted on the addition of ageKeyPlot() to the FSA package for visualizing age-length keys. Since that post, I have added one more type of plot as illustrated below. This post should be considered as an extension of the previous post.

The FSA package is loaded and the same example age-length key is constructed with the following.

library(FSA)
data(WR79)
# get the age sample from the data frame
WR.age <- Subset(WR79, !is.na(age))
# add length categories
WR.age.mod <- lencat(~len,data=WR.age,startcat=35,w=5)
# create age-length key
raw <- table(WR.age.mod$LCat, WR.age.mod$age)
WR.key <- prop.table(raw, margin=1)
round(WR.key,3) # round() for display only
##      
##           4     5     6     7     8     9    10    11
##   35  1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000
##   40  1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000
##   45  1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000
##   50  1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000
##   55  1.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000
##   60  0.600 0.400 0.000 0.000 0.000 0.000 0.000 0.000
##   65  0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000
##   70  0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.000
##   75  0.000 0.889 0.111 0.000 0.000 0.000 0.000 0.000
##   80  0.000 0.250 0.750 0.000 0.000 0.000 0.000 0.000
##   85  0.000 0.000 0.909 0.091 0.000 0.000 0.000 0.000
##   90  0.000 0.000 0.263 0.632 0.105 0.000 0.000 0.000
##   95  0.000 0.000 0.059 0.706 0.176 0.000 0.059 0.000
##   100 0.000 0.000 0.000 0.556 0.167 0.278 0.000 0.000
##   105 0.000 0.000 0.000 0.286 0.429 0.143 0.143 0.000
##   110 0.000 0.000 0.000 0.200 0.200 0.200 0.200 0.200
##   115 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000

Bubble Plot

A “bubble plot” of the proportion of fish in each age for a given length is constructed by including type="bubble" in ageKeyPlot(). The resulting plot shows a circle for each age and length combination in the age-length key and the area of the circle is scaled to be proportional to the percentage of fish of that length that are that age. An example plot is created as follows.

ageKeyPlot(WR.key,type="bubble")

plot of chunk AKbubble1

For example, 100% of the 40-mm length category were age-4, but the ages are much more spread out in the 110-mm length category.

Installing the Latest FSA

Note that the code below requires the latest version of FSA (version 0.4.6). I am now distributing FSA through GitHub; see these new install instructions.

Filed under: Fisheries Science, R Tagged: Age, Age Key, Age-Length Key, R, Visualization

To leave a comment for the author, please follow the link and comment on their blog: fishR » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Sponsors

Mango solutions



plotly webpage

dominolab webpage



Zero Inflated Models and Generalized Linear Mixed Models with R

Quantide: statistical consulting and training

datasociety

http://www.eoda.de





ODSC

ODSC

CRC R books series





Six Sigma Online Training









Contact us if you wish to help support R-bloggers, and place your banner here.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)