R/select_combinatorial_rows_from_table.R

Defines functions select_combinatorial_rows_from_table

Documented in select_combinatorial_rows_from_table

#' Combine cells from table
#' 
#' Iterate over each column of the table and select the cells (via row) to create a combination/permutation.
#' 
#' @param table Either a data frame or matrix, whose cells we wish to combine.
#' @param selection A numeric vector determining the combination/permutation.
#' @return A combination/permutation of cells selected from each column. 
#' @export 

select_combinatorial_rows_from_table = function(selection, table){
  if(!length(selection)==ncol(table)){
    stop("The lenght of selection must be the same as count of columns in table.")
  }
  o = c()
  for(i in 1:length(selection)){
    o = c(o, table[selection[i],i])
  }
  return(o)
}
msxakk89/dat documentation built on Aug. 3, 2020, 6:39 p.m.