Delete Last Vector Element of Vector in R (Example Code)
This tutorial illustrates how to remove the values at the end of a vector in the R programming language.
Creating Example Data
x <- 1:5 # Example vector in R x # Display example vector in RStudio console # [1] 1 2 3 4 5 |
x <- 1:5 # Example vector in R x # Display example vector in RStudio console # [1] 1 2 3 4 5
Example: Removing Last Element of Vector Using head() Function
head(x, - 1) # Delete last vector element # [1] 1 2 3 4 |
head(x, - 1) # Delete last vector element # [1] 1 2 3 4
Further Resources & Related Articles
Here, you may find some additional resources on topics such as vectors, numeric values, and loops.