On 20-Dec-09 21:50:58, 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. > ----------------- > Jane Chang > Queen's
s<-c(1101111,112321) # [A] s/(10^(floor(log10(s))-2)) # [1] 110.1111 112.3210 # [B] sub("([0-9]{3})","\\1.",as.character(s)) [1] "110.1111" "112.321" # [C] as.double(sub("([0-9]{3})","\\1.",as.character(s))) # [1] 110.1111 112.3210 Not sure exactly what you are asking; but these should give some ideas. Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <ted.hard...@manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 20-Dec-09 Time: 22:23:26 ------------------------------ XFMail ------------------------------ ______________________________________________ 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.