Learn R Programming

MQMF (version 0.1.1)

MQMF: MQMF R functions for the New Book

Description

The MQMF package Provides R functions for use with the new book: (Using R for Modelling and Quantitative Methods in Fisheries), being published by CRC Press / Chapman & Hall in their (Using R) series. Currently no vignettes are included but all examples from the chapters are included as help pages for functions. Try ?chapter2, ?chapter3, ..., ?chapter7, which will provide a listing of all the code chunks included in the book (and some that are not). The list of functions below is not complete so scroll to the bottom of any help file and click the link to the index of functions instead. A development version is available on GitHub at github.com/haddonm/MQMF.

Arguments

Some of the utility functions

countones

used in apply to count the ones in a vector

countzeros

used in apply to count the zeros in a vector

countgtzero

halves the height of a tall narrow data.frame

countNAs

used in apply to count the NAs in a vector

countgtone

used in apply to count the numbers > 1 in a vector

freqMean

calculates the mean and st dev count data

getmin

find the minimum of a series to help with ylim or xlim

getmax

find the maximum of a series to help with ylim or xlim

getname

extracts the name of a variable as character

halftable

subdivides a table to make it shorter and wider

magnitude

defines the relative size of parameters for use when using nlm or optim without log-transforming the parameters

makelabel

simplifies combining a name with a vector of numbers for use as a label or a legend entry

outfit

prints a pretty version of the results from optim, nlm, or nlminb

printV

prints a vector of numbers vertically rather than horizontally

quants

used in 'apply' to estimate quantiles across a vector

which.closest

finds the value in a vector closest to a given value.

Some of the plotting and printing functions

addnorm

fits a normal distribution to the output from hist

addlnorm

fits a log-normal distribution to output from hist

inthist

plots a histogram of integer values more precisely than hist.

parset

defines the par statement for a single plot

parsyn

types the standard syntax for the par command to the console

plot1

simplifies the plotting of two variables in a single plot

plotprep

Sets up a window and the par values for a plot. it checks to see if a graphics device is open and opens a new one if not. This is simply a utility function to save typing the standard syntax. Some of the defaults can be changed. Typing the name without () will provide a template for modification. If 'windows' is called repeatedly this will generate a new active graphics device each time leaving the older ones inactive but present. For quick exploratory plots this behaviour is not wanted, hence the check if an active device exists already or not.

printV

returns a vector cbinded to 1:length(invect), which effectively prints the numbers vertically

properties

prints a listing of the properties of the column variables within a data.frame

References

Haddon, M. (2020) Using R for Modelling and Quantitative Methods in Fisheries, CRC Press / Chapman & Hall/ Boca Raton 337p. ISBN: 9780367469894