[R] substring/strsplit question

Erin Hodgess erinm.hodgess at gmail.com
Wed Oct 29 21:57:57 CET 2008

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?


Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodgess at gmail.com

More information about the R-help mailing list