Re: [R] String manipulation and formatting

From: Richard M. Heiberger <rmh_at_temple.edu>
Date: Tue 18 Jul 2006 - 00:42:05 EST


xify <- function(number) {
  fn <- format(number)
  fn3 <- unlist(strsplit(fn, "\\."))
  if (length(fn3) == 1) paste(rep("X", as.numeric(fn3)), collapse="")   else
  paste(paste(rep("X", as.numeric(fn3)[1]-as.numeric(fn3)[2]), collapse=""),

        paste(rep("X", as.numeric(fn3)[2]), collapse=""),
        sep=".")

}

R-help@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 Received on Tue Jul 18 00:59:34 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 18 Jul 2006 - 02:19:42 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.