Description Usage Arguments Details Value Examples
View source: R/separate_data.R
Splits a dataframe in half and returns a new dataframe whose column names match a certain naming pattern.
1 | separate_data(dataframe, column_regex_pattern, inverse = FALSE)
|
dataframe |
a dataframe. |
column_regex_pattern |
character string containing a regular expression that represente the column selection. If an empty chain is passed the dataframe will be returned intact. |
inverse |
logical. The function returns the inverse of the result if this parameter is set to true. |
separate_data splits a dataframe in half according to the names of the columns. This function returns a new dataframe whose column names match a certain naming pattern. Its behaviour can also be reversed. It is based on column selection using the grep function. See documentation grep function for more information about regex.
returns a part of the original dataframe
1 2 3 4 5 6 7 | A_column <- c(1, 2, 3)
B_column <- c(4, 5, 6)
C_column <- c(7, 8, 9)
df <- data.frame(A_column, B_column, C_column)
Bs <- separate_data(df, "^B")
notBs <- separate_data(df, "^B", inverse = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.