Skip to content
Prev 258690 / 398502 Next

UNIX-like "cut" command in R

On Tue, 3 May 2011, Christian Schulz wrote:

            
Thanks.  I did figure that one out a couple of messages back, but to get 
it do behave like "cut -d' ' -f1,4", I had to add a paste command to 
reassemble the parts:

paste(unlist(strsplit(x," "))[c(1,4)], collapse=" ")

Then I wasn't sure if I could do this to every element of a vector of 
strings without looping -- I have to think not.

Mike