I am very new to R. I have a numeric vector, let's say data <- c(1,3, 5, 10, 101)
. What I need is to have every element as a character, add a zero to single digits, and not have more than two characters in every element. I am using the following code:
pad <- str_pad(data, width = 2, side = "left", pad="0")
But this still does not reduce "101" to "10". Any suggestions?
This is different from an earlier thread on padding which does not provide me an answer to how to reduce "101" to "10"