R/PercolationMap.R

## Function to generate a simple percolation map according to the methods described
## in Gardner et al. (1987)
#
#	DimExtents		-	Integer vector describing the length of
#					each dimension
#	Props			-	Integer vector of proportions of the land
#					to designate to each habitat type
#	Cat.Labels		-	Text label to give each category
#
PercolationMap <- function(DimExtents, Props, Cat.Labels = 1:length(Props))
{
	ReCode <- c(NA, rep(Cat.Labels, ceiling(length(Props) / length(Cat.Labels))))
	MapOut <- .External("PercolationMap",
		DimExtents = as.integer(DimExtents),
		Props = as.integer(Props),
		PACKAGE="ecomodtools")
	CodedMapOut <- ReCode[as.integer(MapOut) + 1]
	dim(CodedMapOut) <- DimExtents
	CodedMapOut
}

Try the ecomodtools package in your browser

Any scripts or data that you put into this service are public.

ecomodtools documentation built on May 2, 2019, 4:58 p.m.