Skip to content
Prev 246514 / 398503 Next

vector of character with unequal width

On Wed, Jan 05, 2011 at 03:50:13PM +0000, jose Bartolomei wrote:
[...]
Did you consider something like the following?

  xx <- c("abc", "abcd", "abcde")
  z1 <- rep("000000000", times=length(xx))
  z2 <- substr(z1, 1, 9 - nchar(xx))
  yy <- paste(z2, xx, sep="")
  cbind(yy)
  #     yy         
  #[1,] "000000abc"
  #[2,] "00000abcd"
  #[3,] "0000abcde"

Petr Savicky.