Description Usage Arguments Value See Also Examples
Select columns (or rows) by 'perl' regular expression. See regex{base} for 'regex' documenation. 'regex' is a very powerful grammar to match strings.
1 |
x |
A dataframe, list a matrix with column names or a named numeric. |
pattern |
A search string |
dim |
A character either "c" for selection of columns or "r" for selection of rows, if x is a list this parameter has no meaning |
A Dataframe, list or matrix where the column- or row names match the pattern. By default the selecion is by column, unless the dim parameter specifies "r" for rows. If f x is not a dataframe and if a single column or row is selected 'R' will flatten the results to a vector.
regex{base}
1 2 3 4 5 6 7 8 9 | head(cgrep(iris, "^.+$")) # matches all columns that have non-empty column names and thus
#drops all columns with empty names
head(cgrep(iris, "^Petal\\.")) # matches all columns that have names starting with the
#string "Petal."
head(cgrep(iris, "\\.")) # columns with names that contain a dot
head(cgrep(iris, "\\.[Ww]idth$")) # columns with names ending in the string ".width" or ".Width".
head(cgrep(iris, "^[SP]e.al")) # columns that have names starting with either capital
#'S' or 'P' then an 'e' followed by any character and then 'al'
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.