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 28 in Data Analytics by Rajita
18 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 by anonymous
• 17,870 points

Related Questions In Data Analytics

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,550 points
78 views
0 votes
1 answer
0 votes
1 answer

How to create dummy variables based on a categorical variable of lists in R?

You can use mtabulate in the following way: library(qdapTools) cbind(data[1], ...READ MORE

answered Apr 13, 2018 in Data Analytics by CodingByHeart77
• 3,680 points
405 views
0 votes
1 answer

How to convert a list of dataframes in to a single dataframe using R?

You can use the plyr function: data <- ...READ MORE

answered Apr 13, 2018 in Data Analytics by darklord
• 6,140 points
94 views
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,700 points
65 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,700 points
78 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,700 points
60 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,700 points
41 views
0 votes
1 answer

Top N and Last N records in R Data Frame

Use head() to fetch first N rows ...READ MORE

answered Jul 4 in Data Analytics by anonymous
• 17,870 points
12 views
0 votes
1 answer

Show a list of all variables in R

Hi Swathi, You can use ls() to list ...READ MORE

answered Jun 27 in Data Analytics by Cherukuri
• 17,870 points
27 views