我想打一個清單是這樣的:做一個重複的字母數字列表
"A001:A048", "B001:B048", ..., "Z001:Z048", "AA001:AA048", "BB001:BB048", ...
我看着this thread,但無法弄清楚如何去適應它爲我重複字母。
感謝您的幫助。
我想打一個清單是這樣的:做一個重複的字母數字列表
"A001:A048", "B001:B048", ..., "Z001:Z048", "AA001:AA048", "BB001:BB048", ...
我看着this thread,但無法弄清楚如何去適應它爲我重複字母。
感謝您的幫助。
c(sprintf("%s001:%s048", LETTERS,LETTERS),
sprintf("%s%s001:%s%s048", LETTERS,LETTERS,LETTERS, LETTERS))
下面是使用 「索引替代」(我的術語)與sprintf
一個例子:
outer(LETTERS, 1:26, FUN=sprintf, fmt="%1$s%1$s%2$03d:%1$s%1$s%2$03d")
# [,1] [,2] [,3] [,4] [,5]
[1,] "AA001:AA001" "AA002:AA002" "AA003:AA003" "AA004:AA004" "AA005:AA005"
[2,] "BB001:BB001" "BB002:BB002" "BB003:BB003" "BB004:BB004" "BB005:BB005"
[3,] "CC001:CC001" "CC002:CC002" "CC003:CC003" "CC004:CC004" "CC005:CC005"
[4,] "DD001:DD001" "DD002:DD002" "DD003:DD003" "DD004:DD004" "DD005:DD005"
[5,] "EE001:EE001" "EE002:EE002" "EE003:EE003" "EE004:EE004" "EE005:EE005"
snipped a couple of pages of output
而且一個進一步投籃答:AF 1:48組合:
outer(c(LETTERS,paste("A",LETTERS[1:6],sep="")),
1:48,
FUN=sprintf,
fmt="%1$s%1$s%2$03d")
#-----------------------------------
# [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] "A001" "A002" "A003" "A004" "A005" "A006" "A007" "A008" "A009" "A010"
[2,] "B001" "B002" "B003" "B004" "B005" "B006" "B007" "B008" "B009"
snipped
[,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
snipped
[31,] "AE041" "AE042" "AE043" "AE044" "AE045" "AE046" "AE047" "AE048"
[32,] "AF041" "AF042" "AF043" "AF044" "AF045" "AF046" "AF047" "AF048"
我認爲這是你想要的,即使你的問題不清楚。我使用sprintf
,因爲它使填充前導零更容易。
prefix <- c(LETTERS,paste("A",LETTERS[1:6],sep=""))
out <- sapply(prefix, function(x) sprintf("%s%03d",x,1:48))
as.vector(out) # if you want a vector instead
'out < - outer(前綴,1:48,sprintf,fmt =「%s%03d」)'要簡單得多。 (或者是外部的(1:48,前綴,sprintf,fmt =「%2 $ s%1 $ 03d」),這是轉置)。 – Marek
請不要告訴我那些都是Excel的範圍...... –
沒有,他們是1536孔板是48x32板地圖上的位置。字母是'列',數字是行。我需要索引一些板數據。 – James
哎呀!字母是行(A - AF),數字是列(1 - 48)。 – James