Search code examples
rextract

Trying to extract specific characters in a column in R?


The content in the column appears as follows $1,521+ 2 bds. I want to extract 1521 and put it in a new column. I know this can be done in alteryx using regex can I do it R?


Solution

  • How about the following?:

    library(tidyverse)
    
    x <- '$1,521+ 2 bds'
    
    parse_number(x)