[R] clipping off words inside a vector of strings

2007-10-15 Thread Gonçalo Ferraz
Hi, I have a vector of strings (class character) with 6 elements (length 6). I call it 'names'. "Graham Chapman" "John Cleese" "Terry Gilliam" "Eric Idle" "Terry Jones" "Michael Palin" And I want to turn it into another vector of strings called 'shortnames' with the same length. The new vect

Re: [R] clipping off words inside a vector of strings

2007-10-15 Thread Romain Francois
Lemon Curry ? sapply( strsplit( monty, " " ), function(x) { paste( substring(x,1,3), collapse = " " ) }) is a way to do it, ... There is probably a better way to do that using the gsubfn package Gonçalo Ferraz wrote: > Hi, > > I have a vector of strings (class character) with 6 elements (leng

Re: [R] clipping off words inside a vector of strings

2007-10-15 Thread Marc Schwartz
On Mon, 2007-10-15 at 12:04 -0400, Gonçalo Ferraz wrote: > Hi, > > I have a vector of strings (class character) with 6 elements (length > 6). I call it 'names'. > > "Graham Chapman" > "John Cleese" > "Terry Gilliam" > "Eric Idle" > "Terry Jones" > "Michael Palin" > > And I want to turn it into