I would like to split a vector of names:
names <- c("DOE John", "VAN DYKE Dick", "SMITH Mary Jane")
into two vectors
last <- c("DOE", "VAN DYKE", "SMITH")
and
first <- c("John", "Dick", "Mary Jane")
Any help would be greatly appreciated. Thanks.
This should work:
To match all upper case letters, you could alternatively use the character class
[:upper:], as in:although the documentation at
?regexpseems to mildly warn against doing so, on grounds of reduced portability.