R Programming Running multiple sub-strings

+1 vote

I've created a document that I want to sub-string, so I tired this:

substr(text, start,start+end)

Here, the 'start' var has a vector of 60 elements. The problem is when I run the above code, it returns only the equivalent of substr(text,1109,1109+199). 

I want it to return all the 60 elements, how can this be done?

You can refer my sample data:

start

[1] 11009 11590 11972 15674 16274 16659 19866 20541 20963 24787 25376
[12] 25746 29458 30011 30363 34086 34702 35087 38643 39095 39416 42626
[23] 43188 43545 46731 47367 47757 51029 51673 52072 55444 56076 56470
[34] 59794 60445 60851 64267 64877 65276 68659 69200 69547 72747 73303
[45] 73657 76896 77648 78103 81541 82050 82391 85277 85848 86227 89128
[56] 89656 90010 92830 93329 93656

end

[1] 199 199 199 201 201 201 218 218 218 186 186 186 177 177 177 192 192
[18] 192 160 160 160 178 178 178 194 194 194 200 200 200 197 197 197 205
[35] 205 205 200 200 200 174 174 174 178 178 178 235 235 235 171 171 171
[52] 190 190 190 179 179 179 169 169 169
Feb 6, 2019 in Data Analytics by Tyrion anex
• 8,700 points
469 views

1 answer to this question.

0 votes

Instead of using the substr() try with the substring() function :

substring(your_text,first=start,last=(start+end))
answered Feb 6, 2019 by Sophie may
• 10,610 points

Related Questions In Data Analytics

0 votes
1 answer

Join multiple strings in R

Joining strings in R is quite an ...READ MORE

answered Jul 19, 2018 in Data Analytics by DataKing99
• 8,240 points
1,308 views
+1 vote
3 answers

Filtering R data-frame with multiple conditions

You can use the 'filter' function from ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
86,462 views
0 votes
1 answer

Plotting multiple graphs on the same page in R

If you want to plot 4 graphs ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,660 points
1,169 views
0 votes
2 answers

How to use group by for multiple columns in dplyr, using string vector input in R?

data = data.frame(   zzz11def = sample(LETTERS[1:3], 100, replace=TRUE),   zbc123qws1 ...READ MORE

answered Aug 6, 2019 in Data Analytics by anonymous
13,639 views
+10 votes
3 answers

Which is a better initiative to learn data science: Python or R?

Well it truly depends on your requirement, If ...READ MORE

answered Aug 9, 2018 in Data Analytics by Abhi
• 3,720 points
1,119 views
+1 vote
2 answers
0 votes
1 answer

R programming logic

Use gsub to match the substring that we want ...READ MORE

answered Nov 16, 2018 in Data Analytics by Maverick
• 10,840 points
469 views
0 votes
1 answer
+1 vote
1 answer

R Programming: matrices

Try this, It will test if a matrix ...READ MORE

answered Dec 17, 2018 in Data Analytics by Sophie may
• 10,610 points
415 views
0 votes
1 answer

R programming: Unexpected symbol error

Format your code this way: myfunction <- function() ...READ MORE

answered Dec 17, 2018 in Data Analytics by Sophie may
• 10,610 points
2,827 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP