Re: [R] Get the last 3 chars of a string

2007-10-16 Thread Marc Schwartz
On Tue, 2007-10-16 at 07:49 -0700, Thomas Lumley wrote:
 On Mon, 15 Oct 2007, Gabor Grothendieck wrote:
 
  Here is an alternative:
 
  sub(.*(..)$, \\1, x)
 
 
 For sufficiently small values of 3 ;)

 all.equal(2., 3)
[1] TRUE

;-)

Marc

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Get the last 3 chars of a string

2007-10-15 Thread jim holtman
Looks fine by me.  There are lots of other ways of doing it.  Does
this look any nicer?

 x - c('asdfghk', 'qwerrey')
 gsub(.*(...)$, '\\1', x)
[1] ghk rey



On 10/15/07, Sergio Correia [EMAIL PROTECTED] wrote:
 I want to extract the last 3 letters of a string.

 So far, I've done this:

  symbol = 'XYZ.VX
  substr(symbol,nchar(symbol)-2,nchar(symbol))
 [1] .VX

 It works, but the code looks UGLY as hell. Am I missing something? Or
 is this the way it's supposed to be?

 Thanks,
 Sergio

 On 10/15/07, pintinho [EMAIL PROTECTED] wrote:
 
  Hi everyone,
 
  When I try to import data do R, the following message appears: \U
  sequences are not supported on Windows.
 
  I tried lots of methods to import (read.csv, read.table, RODBC, read.delim)
  and the same message appears for all these methods. I think it is a bigger
  problem.
 
  Can anyone help me solving this issue?
 
  Thanks a lot.
 
 
 
  --
  View this message in context: 
  http://www.nabble.com/ERROR-while-importing-data-tf4628752.html#a13216707
  Sent from the R help mailing list archive at Nabble.com.
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Get the last 3 chars of a string

2007-10-15 Thread Sergio Correia
I was hoping to avoid using regex except when necessary (u know what
they say), but I'm beginning to think that's the way things are done
in R.

Thanks

On 10/15/07, jim holtman [EMAIL PROTECTED] wrote:
 Looks fine by me.  There are lots of other ways of doing it.  Does
 this look any nicer?

  x - c('asdfghk', 'qwerrey')
  gsub(.*(...)$, '\\1', x)
 [1] ghk rey
 


 On 10/15/07, Sergio Correia [EMAIL PROTECTED] wrote:
  I want to extract the last 3 letters of a string.
 
  So far, I've done this:
 
   symbol = 'XYZ.VX
   substr(symbol,nchar(symbol)-2,nchar(symbol))
  [1] .VX
 
  It works, but the code looks UGLY as hell. Am I missing something? Or
  is this the way it's supposed to be?
 
  Thanks,
  Sergio
 
  On 10/15/07, pintinho [EMAIL PROTECTED] wrote:
  
   Hi everyone,
  
   When I try to import data do R, the following message appears: \U
   sequences are not supported on Windows.
  
   I tried lots of methods to import (read.csv, read.table, RODBC, 
   read.delim)
   and the same message appears for all these methods. I think it is a bigger
   problem.
  
   Can anyone help me solving this issue?
  
   Thanks a lot.
  
  
  
   --
   View this message in context: 
   http://www.nabble.com/ERROR-while-importing-data-tf4628752.html#a13216707
   Sent from the R help mailing list archive at Nabble.com.
  
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide 
   http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
  
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


 --
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390

 What is the problem you are trying to solve?


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.