Skip to content
Prev 173697 / 398503 Next

Using format to add leading zeroes

If you have a function that just works on one item at a time then  
sapply will cure that hormonal deficiency. It will even let you  
forward arguments to ... if such are allowed:

 > sapply(vec, "+", 1)
[1] 2 3 4 5 6
 > vec
[1] 1 2 3 4 5
 > sapply(vec, "+", 1)
[1] 2 3 4 5 6