| sub_string | R Documentation |
sub_string() can extract parts of a character from the left side, right side
or from the middle. It is also able to start or end at specific letter sequences
instead of positions.
sub_string(data_frame, variable, from = NULL, to = NULL, case_sensitive = TRUE)
data_frame |
A data frame which contains the variables to concatenate. |
variable |
A character variable to extract parts from. |
from |
The names of the variables to concatenate. |
to |
A single character which will be used to fill up the empty places. |
case_sensitive |
TRUE by default. When a character expression is passed as from or to it makes a difference whether a letter is written in upper or lower case. Pass FALSE to handle upper and lower case equaly. |
Returns parts of a character vector.
Other character manipulating functions: concat(), remove_blanks()
# Example data frame
my_data <- dummy_data(100)
# Extract text from the left
my_data[["left"]] <- my_data |> sub_string(education, to = 2)
# Extract text from the right
my_data[["right"]] <- my_data |> sub_string(education, from = 2)
# Extract text from the middle
my_data[["middle"]] <- my_data |> sub_string(education, from = 2, to = 3)
# Find text and extract from the left
my_data[["left2"]] <- my_data |> sub_string(education, to = "l")
# Find text and extract from the right
my_data[["right2"]] <- my_data |> sub_string(education, from = "l")
# Find text and extract from the middle
my_data[["middle2"]] <- my_data |> sub_string(education, from = "i", to = "l")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.