apc: Assign prey colours

View source: R/apc.r

apcR Documentation

Assign prey colours

Description

Assigns prey colours to prey defined in dataset

Usage

apc(x, preyfile, palette = NULL, check = FALSE)

## S3 method for class 'diet'
apc(x, preyfile, palette = NULL, check = FALSE)

Arguments

x

diet object. Must be of class diet.

preyfile

prey file name that contains the prey groupings and labels required for labelling the tree. The preyfile can be output using the writepn.csv function and then edited accordingly. See writepn.csv for more details.

palette

a vector of colours. This requires the user to set up a colour palette where the number of colours equals the number of prey in x. See colors() for a listing of colours available. By default this is set to NULL.

check

logical. If set to TRUE, the prey colour palette is plotted.

Details

If a colour palette is not provided, then a palette will be automatically derived based on the colour palettes available. For customised colour palettes, users will need to define a palette. If no palette is supplied and there are more than 4 prey groups, the colour palette will default to rainbow.

Value

A list with the following components:

  • colsa vector of node colours for each prey appearing in the diet matrix.

  • xthe updated diet matrix with prey groupings as specified in the PreyTaxonSort.csv file.

References

Kuhnert, P.M., Duffy, L. M and Olson, R.J. (2012) The Analysis of Predator Diet and Stable Isotope Data, Journal of Statistical Software, In Prep.

See Also

colors; palette; topo.colors; heat.colors; terrain.colors

Examples

# Load the YFT diet data (of class diet)
#data(yftdiet)  
#class(yftdiet)
 
# Load the prey taxa data
#data(PreyTaxonSort)
#PreyTaxonSort
 
 
# Example where no palette is given
#val <- apc(x = yftdiet, preyfile = PreyTaxonSort, palette = NULL, check = TRUE)
#node.colsY <- val$cols
#dietPP <- val$x   # updated diet matrix with Group assigned prey taxa codes
#head(dietPP)
 
# Example where palette is given
#pal <- c(topo.colors(10)[1:2], heat.colors(10)[1:2], terrain.colors(25)[1:8])
#val <- apc(x = yftdiet, preyfile = PreyTaxonSort, palette = pal, check = TRUE)
#node.colsY <- val$cols
#dietPP <- val$x   # updated diet matrix with Group assigned prey taxa codes
#head(dietPP)  
 
 
 

pkuhnert/diet documentation built on June 10, 2025, 2:59 a.m.