No need for substring, just use gsub:
gsub( " .*$", "", dob )
# [1] "9/9/43" "9/17/88" "11/21/48"
A space (), then any character (
.
) any number of times (*
) until the end of the string ($
). See ?regex to learn regular expressions.
More Related Contents:
- How to convert string rule to an expression which has a range in R [closed]
- How does one access the piped data.frame in dplyr::funs?
- Split a vector into chunks
- Using ggplot2, can I insert a break in the axis?
- Convert date-time string to class Date
- Filter multiple values on a string column in dplyr
- How do I change the default library path for R packages
- Read all files in a folder and apply a function to each data frame
- Read a text file in R line by line
- R: How to handle times without dates?
- Converting nested list to dataframe
- Assign unique ID based on two columns [duplicate]
- Why TRUE == “TRUE” is TRUE in R?
- the condition has length > 1 and only the first element will be used in if else statement
- Formatting reactive data.frames in Shiny
- What is the significance of the new Reference Classes?
- Setting Defaults for geoms and scales ggplot2
- constrained optimization in R
- Normalizing y-axis in histograms in R ggplot to proportion
- Using get() with replacement functions
- Can I load a saved R object into a new object name?
- Ordering of points in R lines plot
- stumped on how to scrape the data from this site (using R)
- Clarification of L in R
- Convert integer as “20160119” to different columns of “day” “year” “month”
- Is there a way to paste together the elements of a vector in R without using a loop?
- ddply for sum by group in R
- Merge dataframes, different lengths
- Dealing with spaces and “weird” characters in column names with dplyr::rename()
- Filtering rows in R unexpectedly removes NAs when using subset or dplyr::filter