[R] trim function in R

2006-07-24 Thread Wade Wall
Hi all, I am looking for a function in R to trim the last two characters of an 8 character string in a vector. For example, I have the codes 37-079-2, 370079-3,37-079-8 and want to trim them to 37-079 by removing the last two characters. Is sub the correct function to use, and if so how can I

Re: [R] trim function in R

2006-07-24 Thread Gesmann, Markus
PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Wade Wall Sent: 24 July 2006 14:42 To: r-help@stat.math.ethz.ch Subject: [R] trim function in R Hi all, I am looking for a function in R to trim the last two characters of an 8 character string in a vector. For example, I have the codes 37-079-2

Re: [R] trim function in R

2006-07-24 Thread Gabor Grothendieck
A . (dot) matches any character and $ matches the end of string so this replaces the last two characters with the empty string: sub(..$, , x) On 7/24/06, Wade Wall [EMAIL PROTECTED] wrote: Hi all, I am looking for a function in R to trim the last two characters of an 8 character string