[R] String manipulation and formatting

Richard M. Heiberger rmh at temple.edu
Mon Jul 17 16:42:05 CEST 2006


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=".")
}



More information about the R-help mailing list