R/centroidSize.R

Defines functions centroidSize

Documented in centroidSize

centroidSize <- function(m){

	if(is.array(m) && length(dim(m)) > 2){
		r <- rep(NA, dim(m)[3])
		for(i in 1:dim(m)[3]){

			n <- na.omit(m[,, i])
		
			# CENTER
			n <- n - matrix(colMeans(n), nrow=nrow(n), ncol=ncol(n), byrow=TRUE)
		
			# FIND CENTROID SIZE
			r[i] <- sqrt(sum(n^2))
		}
		return(r)
	}else{
		m <- na.omit(m)
	
		# CENTER
		m <- m - matrix(colMeans(m), nrow=nrow(m), ncol=ncol(m), byrow=TRUE)
	
		# FIND CENTROID SIZE
		r <- sqrt(sum(m^2))
	}
	r
}

Try the linkR package in your browser

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

linkR documentation built on May 2, 2019, 2:14 p.m.