View source: R/classify_files.R
| classify_files | R Documentation |
Classifies entries into categories (blank, standard, pool, sample, …) based on pattern rules applied to a specific search column. The identifiers returned in each category are also configurable.
classify_files(
fi,
search_col = "link_rawdata",
id_col = "file_id",
patterns = list(blank = c("blk", "blank", "MQ"), standard = c("srfa", "standard"), pool
= c("pool")),
include_blank_check = TRUE,
return = c("list", "table")
)
fi |
|
search_col |
Character. Name of the column used for pattern matching.
Defaults to |
id_col |
Character. Name of the column whose values are returned for
each category. Defaults to |
patterns |
Named list of character vectors. Each list entry is a category name, and its value is a vector of patterns. |
include_blank_check |
Logical; if TRUE and |
return |
Either
|
Default behavior:
"blank": blank_check == "blank" or pattern "blk"
"standard": pattern "srfa"
"pool": pattern "pool"
"sample": everything unmatched
Pattern matching is case-insensitive.
Named list or a classified data.table.
# Minimal demo data
fi <- data.table::data.table(
file_id = 1:6,
filename = c("NS_blk_01.raw", "SRFA_20.raw", "Pool_A.raw",
"Sample_01.raw", "Sample_02.raw", "MQ_blank.raw"),
blank_check = c("blank", NA, NA, NA, NA, "blank"), # optional column
link_rawdata = c("NS_blk_01.raw", "SRFA_20.raw", "Pool_A.raw",
"Sample_01.raw", "Sample_02.raw", "MQ_blank.raw")
)
# 1) Default behavior: return named list of file_ids by category
classify_files(fi)
# 2) Use a different column for pattern matching
classify_files(fi, search_col = "filename")
# 3) Return another ID field (here: file_id → stays the same for demo)
classify_files(fi, id_col = "file_id")
# 4) Return the full table with new category column
classify_files(fi, return = "table")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.