substring of last N characters in R

0 votes
How to store substring of last N characters from a data frame field in R?
Jun 29, 2019 in Data Analytics by Rajita
635 views

1 answer to this question.

0 votes

Use below code - 

If the elements within the field have fixed length then directly give the position values like below - 

substring(table$field_name,4,8)

If the length of elements in the field is varying then use nchar() to find the length of string like below -

substring(table$field_name,nchar(table$field_name)-4,nchar(table$field_name))
answered Jul 4, 2019 by anonymous
• 33,030 points

Related Questions In Data Analytics

0 votes
0 answers

Extracting the last n characters from a string in R

The final n characters of a string ...READ MORE

Jun 27, 2022 in Data Analytics by avinash
• 1,840 points
531 views
0 votes
0 answers

Extracting the last n characters from a string in R

See the code below: library(dslabs) data(gapminder) differenceminder percent > percent filter(year% ...READ MORE

Jul 5, 2022 in Data Analytics by avinash
• 1,840 points
446 views
0 votes
1 answer

Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

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

By using dpylr package sum of multiple columns

Basically here we are making an equation ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
2,219 views
0 votes
1 answer

How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
1,882 views
0 votes
1 answer

In a dpylr pipline how to use sample and seq?

For avoiding rowwise(), I prefer to use ...READ MORE

answered Apr 6, 2018 in Data Analytics by DeepCoder786
• 1,720 points

edited Jun 9, 2020 by Gitika 1,143 views
0 votes
1 answer

How to create a list of Data frames?

Basically all we have to do is ...READ MORE

answered Apr 9, 2018 in Data Analytics by DeepCoder786
• 1,720 points
1,287 views
0 votes
2 answers

Top N and Last N records in R Data Frame

Hi, top_n( ) and top_frac( ) also is ...READ MORE

answered Sep 3, 2019 in Data Analytics by anonymous
• 33,030 points
5,097 views
+2 votes
2 answers

Change data type of one column in R

You can change data types using as.* ...READ MORE

answered Aug 16, 2019 in Data Analytics by anonymous
• 33,030 points
121,129 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