[R] insert a dot to the numbers

Marc Schwartz marc_schwartz at me.com
Sun Dec 20 23:10:26 CET 2009


On Dec 20, 2009, at 3:50 PM, rusers.sh wrote:

> Hi,
>  Anybody can give me some hints on the following problem?
> s<-c(1101111,112321)
>  I want to insert a dot "." after the third number and get the  
> following
> results.
> 110.1111
> 112.321
>
>  Thanks a lot.



s <- c(1101111, 112321)

 > s / (10 ^ (nchar(s) - 3))
[1] 110.1111 112.3210


See ?nchar
 > nchar(s)
[1] 7 6


HTH,

Marc Schwartz




More information about the R-help mailing list