R/thin.S

Defines functions thin

Documented in thin

# Copyright Barry Rowlingson <b.rowlingson@lancaster.ac.uk> and 
# Peter Diggle (c) 1991-3; http://www.maths.lancs.ac.uk/~rowlings/Splancs/
# R port: copyright 1998-2000 by Roger S. Bivand

thin <- function(pts,n)
{
	pts <- as.points(pts)
	nptsi <- npts(pts)
	if(nptsi<n)
	{
		warning(paste("Requested ",n," points from data with ",nptsi,".\n"))
		n <- nptsi
	}
	if(nptsi==0 | n==0)
	{
		pts <- NULL
	}
	else
	{
		pts[sample(1:nptsi)[1:n],]
	}
}

Try the splancs package in your browser

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

splancs documentation built on Aug. 21, 2023, 9:08 a.m.