With a regular expression and the function gsub()
:
group <- c("12357e", "12575e", "197e18", "e18947")
group
[1] "12357e" "12575e" "197e18" "e18947"
gsub("e", "", group)
[1] "12357" "12575" "19718" "18947"
What gsub
does here is to replace each occurrence of "e"
with an empty string ""
.
See ?regexp
or gsub
for more help.
Related Contents:
- Replace multiple letters with accents with gsub
- Replace / translate characters in a string
- Remove all punctuation except apostrophes in R
- How to remove unicode from string?
- gsub() in R is not replacing ‘.’ (dot)
- Remove everything after space in string
- grep using a character vector with multiple patterns
- Matching multiple patterns
- Selecting data frame rows based on partial string match in a column
- How to remove all whitespace from a string?
- How to use grep()/gsub() to find exact match
- Replace single backslash in R
- Using regex in R to find strings as whole words (but not strings as part of words)
- How to replace NA values in a table for selected columns
- Replace NA in column with value in adjacent column
- Test if characters are in a string
- Remove parentheses and text within from strings in R
- POSIX character class does not work in base R regex
- Replace all particular values in a data frame
- Remove part of a string
- Match values in data frame with values in another data frame and replace former with a corresponding pattern from the other data frame
- Replace multiple strings in one gsub() or chartr() statement in R?
- regular expressions in base R: ‘perl=TRUE’ vs. the default (PCRE vs. TRE)
- Finding the indexes of multiple/overlapping matching substrings
- Remove all text before colon
- How to replace NaN value with zero in a huge data frame?
- Extracting unique numbers from string in R
- Replace given value in vector
- R – gsub replacing backslashes
- R: Replace multiple values in multiple columns of dataframes with NA
- Replace values in a vector based on another vector
- Replace all values in a matrix
- Replace a value NA with the value from another column in R
- Select columns based on string match – dplyr::select
- Use grepl to search either of multiple substrings in a text [duplicate]
- Replacing occurrences of a number in multiple columns of data frame with another value in R
- grepl for a period “.” in R?
- Replace in a factor column
- R grep: is there an AND operator?
- Replace empty values with value from other column in a dataframe
- select columns based on multiple strings with dplyr contains()
- Remove pattern from string with gsub
- Replace missing values (NA) with most recent non-NA by group
- pull out p-values and r-squared from a linear regression
- Using spread with duplicate identifiers for rows
- Controlling the order of points in ggplot2?
- How can I obtain an ‘unbalanced’ grid of ggplots?
- Dynamically build call for lookup multiple columns
- RMarkdown: How to end tabbed content
- How to make time difference in same units when subtracting POSIXct