Improved docs

This commit is contained in:
Waldir Leoncio 2020-11-09 07:31:33 +01:00
parent 1dca4b290e
commit 03bec3b4b4
9 changed files with 19 additions and 90 deletions

View file

@ -1,4 +1,7 @@
#'@title Seuraavat kolme funktiota liittyvat alkupartition muodostamiseen.
#' @title Seuraavat kolme funktiota liittyvat alkupartition muodostamiseen.
#' @param data_matrix data_matrix
#' @param nclusters ncluster
#' @param Z Z
admixture_initialization <- function (data_matrix, nclusters, Z) {
size_data <- size(data_matrix)

16
R/min.R
View file

@ -1,16 +0,0 @@
#' @title Minimum (MATLAB version)
#' @description Finds the minimum value for each column of a matrix, potentially returning the indices instead
#' @param X matrix
#' @param indices return indices?
#' @return Either a list or a vector
#' @author Waldir Leoncio
#' @export
min_MATLAB <- function(X, indices = TRUE) {
mins <- apply(X, 2, min)
idx <- sapply(seq_len(ncol(X)), function(x) match(mins[x], X[, x]))
if (indices) {
return(list(mins = mins, idx = idx))
} else {
return(mins)
}
}

View file

@ -1,35 +0,0 @@
#' @title Minimum (MATLAB version)
#' @description Finds the minimum value for each column of a matrix, potentially returning the indices instead
#' @param X matrix
#' @param indices return indices?
#' @return Either a list or a vector
#' @author Waldir Leoncio
#' @export
min_MATLAB <- function(X, indices = TRUE) {
mins <- apply(X, 2, min)
idx <- sapply(seq_len(ncol(X)), function(x) match(mins[x], X[, x]))
if (indices) {
return(list(mins = mins, idx = idx))
} else {
return(mins)
}
}
#' @title Minimum (MATLAB version)
#' @description Finds the minimum value for each column of a matrix, potentially returning the indices instead
#' @param X matrix
#' @param indices return indices?
#' @return Either a list or a vector
#' @author Waldir Leoncio
#' @export
min_MATLAB <- function(X, indices = TRUE) {
mins <- apply(X, 2, min)
idx <- sapply(seq_len(ncol(X)), function(x) match(mins[x], X[, x]))
if (indices) {
return(list(mins = mins, idx = idx))
} else {
return(mins)
}
}
# TODO: consider using methods instead (maybe for the package)

View file

@ -1,12 +1,11 @@
#' @title Set differences of two arrays
#' @description Loosely replicates the behavior of the homonym Matlab function
#' @param A first array
#' @param B second awway
#' @param legacy if `TRUE`, preserves the behavior of
#' @return
#' @param B second array
#' @param legacy if `TRUE`, preserves the behavior of the setdiff function from MATLAB R2012b and prior releases. (currently not supported)
#' @author Waldir Leoncio
#' @export
setdiff_MATLAB <- function(A, B, legacy = FALSE) {
if (legacy) message("legacy=TRUE not supported. Ignoring.")
if (is(A, "numeric") & is(B, "numeric")) {
values <- sort(unique(A[is.na(match(A, B))]))
} else if (is(A, "data.frame") & is(B, "data.frame")) {