Get all but the last item in an R list

Viewed 702
x <- list("item one", "item two", "item three")

If I wanted to select all but the last item in Python, I would use x[:-1]. How do I do this in R?

2 Answers

We can tell R to take one less than the length of the entire vector: x[1:length(x)-1]

Related