R/Bounded_weights.R

Defines functions Bounded_weights

Documented in Bounded_weights

#' Add weights to the data, bound at a maximum.
#' 
#' @param S   Sample data matrix – a matrix of pigment samples
#' @param weight.upper.bound  Upper bound for weights (default is 30)        
#'
#' @return A vector with upper bounds for weights
#' @export
#'
#' @examples
#' Bounded_weights(Sm, weight.upper.bound = 30)
#' 
Bounded_weights <-function(S, weight.upper.bound = 30){
  n <- colMeans(S)
  S <- n^-1
  S <- ifelse(S > weight.upper.bound, weight.upper.bound, S)
  S[length(S)] = 1
  return(S)
}

Try the phytoclass package in your browser

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

phytoclass documentation built on April 4, 2025, 4:02 a.m.