- Related Questions & Answers
- How to remove some last elements of a vector in R?
- How to replace a value in an R vector?
- How to remove only last character from a string vector in R?
- How to find the index of the last occurrence of repeated values in a vector in R?
- How to check if a vector contains a given value in R?
- How to find the position of a non-NA value in an R vector?
- How to set a specific value for a range in an R vector?
- How to find minimum value in a numerical vector which is written as a character vector in R?
- How to reverse a vector in R?
- How to find the index of the minimum and maximum value of a vector in R?
- How to calculate the number of elements greater than a certain value in a vector in R?
- How to replace values in a vector with values in the same vector in R?
- How to convert unit of measurements of a value or a vector in R?
- How to find the range of a vector in R?
- How to access the table values in R?

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

This can be done by using tail function.

> x<-c(253,254,36,874,351,651,245,274,19,1095) > tail(x,n=1) [1] 1095 > data <- data.frame(Class=c("Highschool","Highschool","Graduate","Graduate", "Graduate","Graduate","Masters","Masters","Masters","PhD")) > tail(data,n=1) Class 10 PhD df = data.frame(matrix(rnorm(20), nrow=5)) > tail(df,n=1) X1 X2 X3 X4 5 -0.3595053 0.9943738 0.959761 -0.6565688 > tail(df$X4,n=1) [1] -0.6565688

Advertisements