[Analogue-commits] r178 - in pkg: . R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Jun 28 19:25:39 CEST 2010
Author: gsimpson
Date: 2010-06-28 19:25:39 +0200 (Mon, 28 Jun 2010)
New Revision: 178
Added:
pkg/R/chooseTaxa.R
pkg/man/chooseTaxa.Rd
Modified:
pkg/DESCRIPTION
pkg/inst/ChangeLog
Log:
add function chooseTaxa and document, bump package version
Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION 2010-06-23 20:53:54 UTC (rev 177)
+++ pkg/DESCRIPTION 2010-06-28 17:25:39 UTC (rev 178)
@@ -1,9 +1,9 @@
Package: analogue
Type: Package
Title: Analogue and weighted averaging methods for palaeoecology
-Version: 0.6-24
+Version: 0.6-25
Date: $Date$
-Depends: R (>= 2.5.0), stats, graphics, vegan, lattice, grid, MASS
+Depends: R (>= 2.5.0), stats, graphics, vegan, lattice, grid, MASS, princurve
Author: Gavin L. Simpson, Jari Oksanen
Maintainer: Gavin L. Simpson <gavin.simpson at ucl.ac.uk>
Description: Fits Modern Analogue Technique and Weighted Averaging transfer
Added: pkg/R/chooseTaxa.R
===================================================================
--- pkg/R/chooseTaxa.R (rev 0)
+++ pkg/R/chooseTaxa.R 2010-06-28 17:25:39 UTC (rev 178)
@@ -0,0 +1,18 @@
+chooseTaxa <- function(object, ...) {
+ UseMethod("chooseTaxa")
+}
+
+chooseTaxa.default <- function(object, n.occ = 1, max.abun = 0,
+ type = c("AND","OR"), ...) {
+ if(missing(type))
+ type <- "AND"
+ type <- match.arg(type)
+ occ.want <- colSums(object > 0) >= n.occ
+ abun.want <- apply(object, 2, max) >= max.abun
+ want <- if(isTRUE(all.equal(type, "AND"))) {
+ occ.want & abun.want
+ } else {
+ occ.want & abun.want
+ }
+ return(object[,want])
+}
Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog 2010-06-23 20:53:54 UTC (rev 177)
+++ pkg/inst/ChangeLog 2010-06-28 17:25:39 UTC (rev 178)
@@ -1,5 +1,11 @@
analogue Change Log
+Version 0.6-25
+
+ * chooseTaxa: new function to select species on basis of number
+ of occurrences and maximum abundance. Function is an S3 generic
+ with a default method.
+
Version 0.6-24
* Dependencies: package now depends on package 'grid'.
Added: pkg/man/chooseTaxa.Rd
===================================================================
--- pkg/man/chooseTaxa.Rd (rev 0)
+++ pkg/man/chooseTaxa.Rd 2010-06-28 17:25:39 UTC (rev 178)
@@ -0,0 +1,57 @@
+\name{chooseTaxa}
+\alias{chooseTaxa}
+\alias{chooseTaxa.default}
+\title{Select taxa (variables) on basis of maximum abundance attained
+ and number of occurrences}
+\description{
+ Select taxa (variables) from an object on the basis of one or both of
+ maximum abundance and number of occurrences greater than user-specified
+ values. This is a simple utility function to encapsulate this common
+ task in filtering palaeoecological data sets.
+}
+\usage{
+chooseTaxa(object, \dots)
+
+\method{chooseTaxa}{default}(object, n.occ = 1, max.abun = 0,
+ type = c("AND","OR"), \dots)
+}
+%- maybe also 'usage' for other objects documented here.
+\arguments{
+ \item{object}{an R object for which a suitable method exists. The
+ default method assumes a matrix-like object such as a data
+ frame or a numeric matrix.}
+ \item{n.occ}{numeric; number of occurrences representing the lower
+ limit for selection. A taxon is included in the returned subset if
+ it is present a total of \code{n.occ} times or more. See argument
+ \code{type} for a modifier which might exclude the taxon even if it
+ would be included on the basis of \code{n.occ}.}
+ \item{max.abun}{numeric; maximum abundance representing the lower
+ limit for selection. A taxon is included in the returned subset if
+ it attains abundance equal to or greater than \code{max.abun} in one
+ or more sample. See argument \code{type} for a modifier which might
+ exclude the taxon even if it would be included on the basis
+ of \code{max.abun}.}
+ \item{type}{character; one of \code{"AND"} or \code{"OR"}, controlling
+ how the criteria \code{n.occ} and \code{max.abun} are combined to
+ generate a subset of the variables in \code{object}.}
+ \item{\dots}{arguments passed on to subsequent methods.}
+}
+%\details{
+%}
+\value{
+ Returns the supplied data frame or matrix with a subset of columns
+ (taxa) that meet the criteria chosen.
+}
+%\references{
+%}
+\author{Gavin L. Simpson}
+%\seealso{
+%}
+\examples{
+data(ImbrieKipp)
+IK2 <- chooseTaxa(ImbrieKipp, n.occ = 5)
+dim(ImbrieKipp)
+dim(IK2)
+}
+\keyword{methods}
+\keyword{multivariate}
More information about the Analogue-commits
mailing list