vec_day2 <- sprintf("%03d", vec_day)
[1] "008" "014" "365" "009"
Put '00's in front of integers based on how large the number is?
Question
I have a vector of calendar days such as vec_day
vec_day<- c(8,14,365,9)
vec_day
[1] 8 14 365 9
I would like to transform this to vec_day2
vec_day2
[1] "008" "014" "365" "009"
It can be either a string or a vector
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow