## untested

last <- tail(x, n = 1)
first <- head(x, n = length(x) - 1)

Erin Hodgess wrote:
Dear R People:

Here is a toy example:

x <- c("2E","5W","12H")
substr(x,2,2)
[1] "E" "W" "2"

Sometimes x has 3 elements, sometimes 2.  I want to extract the last
element, and then extract the other 1 or 2 elements.

How can I do this, please?

TIA,
Sincerely,
Erin



______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to