-1

I'm wondering how to create 4 back-to-back, ordered vectors of characters each beginning from "A01" and ending in "A15" using paste0 or a better regular expression code (see the full vector below)?

I have tried the following (with no success):

rep(paste0("A", 0, 1:15), 4)

Here is the full vector I'm trying to achieve using paste0:

G = c("A01", "A02", "A03", "A04", "A05", "A06", "A07", "A08", "A09", "A10", "A11", "A12", 
      "A13", "A14", "A15", "A01", "A02", "A03", "A04", "A05", "A06", "A07", "A08", "A09", 
      "A11", "A12", "A13", "A14", "A15","A01", "A02", "A03", "A04", "A05", "A06", "A07", 
      "A08", "A09", "A12", "A13", "A14", "A15","A01", "A02", "A03", "A04", "A06", "A07", 
      "A08", "A09", "A12", "A13", "A14", "A15","A01", "A02", "A03", "A04", "A05", "A06", 
      "A07", "A08", "A09", "A10", "A11", "A12", "A13", "A14", "A15")
rnorouzian
  • 7,397
  • 5
  • 27
  • 72

1 Answers1

0
sapply(1:15, (function(i) {paste0("A", rep(0, (2-nchar(as.character(i)))), i)} ))
Damiano Fantini
  • 1,925
  • 9
  • 11