Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Extracting nth character till the end of string in R

$
0
0

I'm trying to extract the nth character onwards in a string, using R. Here's my data:

StringField
example_string1
example_string2
example_string3
example_string4
example_string5
example_string6
example_string7
example_string8
example_string9
example_string10
example_string11
example_string12

I want to extract only the numbers after example_string, so the result would be:

1
2
3
4
5
6
7
8
9 
10
11
12

I've tried something along the lines of:

df$unique_number <- substr(df$stringField, 15:)

to indicate I want everything from the 15th position onward, till the end of the string. Any thoughts on an easy way to accomplish what I'm trying to do? thanks!


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>