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, 2019 in Data Analytics by Rajita
116 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
• 32,890 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,620 points
2,765 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,720 points
1,147 views
+1 vote
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 Sahiti
• 6,360 points
1,614 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,720 points
1,039 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
544 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 216 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
353 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
• 32,890 points
2,530 views
+1 vote
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
• 32,890 points
2,823 views