Skip to contents

This function extracts a rectangular block from a dataframe using user-specified top/bottom row indices and left/right column identifiers (numeric or Excel-style letters). It ensures the block contains only numeric values or NAs, and returns a cleaned matrix.

Usage

extract_data(
  data,
  bottom_row,
  right_col,
  top_row = 1,
  left_col = 1,
  feature_name_columns = NA,
  use_row_index = FALSE
)

Arguments

data

A dataframe containing the full input, including annotation columns and the numeric block to extract.

bottom_row

Integer. Specifies the last (bottom) row of the numeric data block. Must be >= `top_row`.

right_col

Same format as `left_col`. Specifies the right-most column of the numeric block. Must be >= `left_col` after conversion.

top_row

Integer. Specifies the first (top) row of the numeric data block. Row indexing is 1-based.

left_col

Column specifier for the left-most column of the data block. Can be either: - An integer index (e.g., 2 for the second column), or - A character string using Excel-style letters (e.g., "A", "AB").

Column names (e.g., "age") are **not** allowed here. Only letters or numeric indices are accepted.

feature_name_columns

Optional character vector specifying columns in `data` to be used as row (feature) names in the output. If `NA`, generic feature names are used.

use_row_index

Logical. If TRUE, prepend the row index to each combined feature name to ensure uniqueness. Defaults to FALSE.

Value

A numeric matrix with cleaned values and appropriate column names.