Find colname by character string or pattern matching
Usage
find_colname(
pattern,
x,
max = 1,
index = FALSE,
require_non_na = TRUE,
verbose = FALSE,
...
)Arguments
- pattern
character vector containing text strings or regular expression patterns.
- x
input
data.frameor other R object that contains colnames.- max
integer maximum number of results to return.
- index
logical indicating whether to return the column index as an integer vector. When
index=FALSEit returns the matchingcolnames(x); whenindex=TRUEit returns the matching column numbers as an integer vector.- require_non_na
logical indicating whether to require the column to contain non-NA values, default is TRUE. The intent of this function is to find colnames whose data will match expectations, and when require_non_na is TRUE, this function will continue until it finds a column with non-NA values.
- ...
additional arguments are passed to
jamba::provigrep().
Value
character vector with length max, or if no pattern
match is found it returns NULL. Also if there are no
colnames(x) then it returns NULL.
Details
This function is intended to help find a colname given
a character vector of expected values or regular expression
patterns. By default it returns the first matching value,
but can return multiple if max=Inf.
If there are no colnames(x) then NULL is returned.
The order of operations:
Match exact string.
Match exact string in case-insensitive manner.
Match the start of each string using
jamba::provigrep().Match the end of each string using
jamba::provigrep().Match each string using
jamba::provigrep().
The results from the first successful operation is returned.
When there are duplicate colnames(x) only the first
unique name is returned.
See also
Other jam utility functions:
ashape(),
avg_angles(),
avg_colors_by_list(),
bulk_cnet_adjustments(),
call_fn_ellipsis_deprecated(),
cell_fun_bivariate(),
collapse_mem_clusters(),
colorRamp2D(),
deconcat_df2(),
display_colorRamp2D(),
enrichList2geneHitList(),
filter_mem_genes(),
filter_mem_sets(),
find_enrich_colnames(),
get_hull_data(),
get_igraph_layout(),
gsubs_remove(),
handle_igraph_param_list(),
isColorBlank(),
make_legend_bivariate(),
make_point_hull(),
mem_find_overlap(),
order_colors(),
rank_mem_clusters(),
rotate_coordinates(),
subgraph_jam(),
subset_mem(),
summarize_node_spacing(),
xyAngle()