ez.selcol: select col names in a df

View source: R/frame.R

ez.selcolR Documentation

select col names in a df

Description

select col names in a df, evaluated by sprintf('dplyr::select(df,

Usage

ez.selcol(df, col = NULL, ...)

Arguments

df

df

col

a string or a vector or NULL (NULL=all cols)
recommended usage:
c("sample_num","mother_num") (not quoted)
1:4 (not quoted), c(2,1,3) –> the returned order will be 2,1,3 (not in original df col order)
'col1:col3', 'col3:col5, col7:col8', (quoted)
'-(ABCB1_c1236t:pgp_rs2032582)', '-c(neonate_admit_NICU,BDNF)' (quoted)

OK usage:
'c(sample_num,mother_num)', 'sample_num,mother_num', '1, col3:col5, col7:col8'

Value

returns vector of col names (if no col matched, resturn NULL, for easy later use with c(NULL,'a col') -> c('a col'))

Examples

regular expression should use four slashes \\
'matches("cci[i]?\\\\d\\\\d$")'

jerryzhujian9/ezmisc documentation built on March 9, 2024, 12:44 a.m.