R/normalize_data.R

Defines functions normalize_data

Documented in normalize_data

#' Normalize Data
#'
#' Normalizes matrix format data
#'
#' @param x a matrix containing the values of direct relationship decision matrix.
#' @param data_control is a pre-defined logical parameter that whether data should checked.
#'
#' @return This function returns a \code{list} of data, and normalized matrix.
#'
#' @export
#'
normalize_data <- function(x , data_control = TRUE) {

  if (data_control == TRUE) {
    x <- check_data(x)
  }

  sum_of_rows <- apply(x, 1, sum)
  sum_of_columns <- apply(x, 2, sum)
  maximum_of_rows_and_column <- max(sum_of_rows, sum_of_columns)
  return(normalized_matrix = round(x/maximum_of_rows_and_column, 5))
}

Try the dematel package in your browser

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

dematel documentation built on Feb. 22, 2021, 5:08 p.m.