View source: R/S03_Utilities.R
column | R Documentation |
A function that matches or excludes column names in a data frame based on user-supplied sub-strings.
column(dtf, ...)
dtf |
A data frame. |
... |
Character strings with the sub-strings to match
(or exclude) against the column names in |
A vector of column names meeting the inclusion and exclusion criteria.
Kevin Potter
# Create a data frame
dtf <- data.frame(
IDS.INT.Subject = rep( 1:4, each = 2 ),
SSS.CHR.Group = rep( c( 'A', 'A', 'B', 'B' ), each = 2 ),
SSS.INT.Group = rep( c( 1, 1, 2, 2 ), each = 2 ),
SSS.LGC.Group_A = rep( c( T, T, F, F ), each = 2 ),
SSS.CHR.Time_point = rep( c( 'Pre', 'Post' ), 4 ),
SSS.INT.Time_point = rep( 0:1, 4 ),
OUT.DBL.Scores = rnorm( 8 )
)
#' # All variables containing 'SSS'
column( dtf, 'SSS' )
# All variables containing both 'SSS' and 'CHR'
column( dtf, 'SSS', 'CHR' )
# Variables containing 'SSS' but not 'CHR'
column( dtf, 'SSS', '~CHR' )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.