vibhu vibhu - 3 years ago 159
R Question

how to read numbers from text

input output
car number and model 400708

how to read just numeric form


input output
car number and model 400708

how to read just numeric form from the above data


input output
car number and model 400708

how to read just numeric form from the above data

Answer Source

We can use sub to extract

df1$output <- as.numeric(sub(".*\\s+", "", df1$input))

Or if this is based on position, use substring

substring(df1$input, nchar(df1$input)-5)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download