[R] simple coding question

Peter Alspach PAlspach at hortresearch.co.nz
Tue Jul 31 07:17:29 CEST 2007


Kirsten

One way to do this:

kirsten <- c(123, 1234, 12345)
100*as.numeric(paste(substring(kirsten, 1, 3), substring(kirsten, 4, 5),
sep='.'))

HTH ........

Peter Alspach
  

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Kirsten Beyer
> Sent: Tuesday, 31 July 2007 9:31 a.m.
> To: r-help at stat.math.ethz.ch
> Subject: [R] simple coding question
> 
> I have a list of ICD9 (disease) codes with various formats - 3 digit,
> 4 digit, 5 digit.  The first three digits of these codes are 
> what I am most interested in.  I would like to either add 
> zeros to the 3 and 4 digit codes to make them 5 digit codes 
> or add decimal points to put them all in the format ###.##.  
> I did not see a function that allows me to do this in the 
> formatting command.  This seems simple - can someone help?
> 
> Thanks,
> K.Beyer
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
> 

______________________________________________________

The contents of this e-mail are privileged and/or confidenti...{{dropped}}



More information about the R-help mailing list