View source: R/feature_manipulation.R
| feature_manipulation | R Documentation |
Filters features (variables) in a matrix or data frame by removing those with missing values, non-numeric types, infinite values, or zero variance. This is useful for preparing data for downstream statistical analyses.
feature_manipulation(
data,
feature = NULL,
is_matrix = FALSE,
print_result = FALSE
)
data |
A matrix or data frame containing features to filter. |
feature |
Character vector of feature names to check. If 'is_matrix = TRUE', features are extracted from row names of the matrix. |
is_matrix |
Logical indicating whether 'data' is a gene expression matrix (features as rows, samples as columns). If 'TRUE', the matrix is transposed for processing. Default is 'FALSE'. |
print_result |
Logical indicating whether to print filtering statistics. Default is 'FALSE'. |
Character vector of feature names that pass all quality checks.
Dongqiang Zeng
set.seed(123)
test_data <- data.frame(
A = c(1, 2, 3),
B = c(1, 1, 1), # zero variance
C = c(1, NA, 3), # missing value
D = c("a", "b", "c") # non-numeric
)
feas <- feature_manipulation(data = test_data, feature = colnames(test_data), print_result = TRUE)
print(feas)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.