石田さんのページで
Rの備忘録
アルファベットの組み合わせを文字ベクトルとして作成する方法
for( i in 0:2 ){
AA 1
AB 2
AC 3
:
AY 25
AZ 26
BA 27
BB 28
BC 29
BD 30
...
以下のようにすることも
> paste(LETTERS[rep(1:3, each=26)],LETTERS[rep(1:26, 3)], sep="")
[1] "AA" "AB" "AC" "AD" "AE" "AF" "AG" "AH" "AI" "AJ" "AK" "AL" "AM" "AN" "AO" "AP"
[17] "AQ" "AR" "AS" "AT" "AU" "AV" "AW" "AX" "AY" "AZ" "BA" "BB" "BC" "BD" "BE" "BF"
[33] "BG" "BH" "BI" "BJ" "BK" "BL" "BM" "BN" "BO" "BP" "BQ" "BR" "BS" "BT" "BU" "BV"
[49] "BW" "BX" "BY" "BZ" "CA" "CB" "CC" "CD" "CE" "CF" "CG" "CH" "CI" "CJ" "CK" "CL"
[65] "CM" "CN" "CO" "CP" "CQ" "CR" "CS" "CT" "CU" "CV" "CW" "CX" "CY" "CZ"
Rの備忘録
アルファベットの組み合わせを文字ベクトルとして作成する方法
for( i in 0:2 ){
for(j in 1: length(LETTERS)){
}cat( paste(LETTERS[i+1], LETTERS[j], sep = ""),
}i * length(LETTERS) + j, "\n" )
AA 1
AB 2
AC 3
:
AY 25
AZ 26
BA 27
BB 28
BC 29
BD 30
...
以下のようにすることも
> paste(LETTERS[rep(1:3, each=26)],LETTERS[rep(1:26, 3)], sep="")
[1] "AA" "AB" "AC" "AD" "AE" "AF" "AG" "AH" "AI" "AJ" "AK" "AL" "AM" "AN" "AO" "AP"
[17] "AQ" "AR" "AS" "AT" "AU" "AV" "AW" "AX" "AY" "AZ" "BA" "BB" "BC" "BD" "BE" "BF"
[33] "BG" "BH" "BI" "BJ" "BK" "BL" "BM" "BN" "BO" "BP" "BQ" "BR" "BS" "BT" "BU" "BV"
[49] "BW" "BX" "BY" "BZ" "CA" "CB" "CC" "CD" "CE" "CF" "CG" "CH" "CI" "CJ" "CK" "CL"
[65] "CM" "CN" "CO" "CP" "CQ" "CR" "CS" "CT" "CU" "CV" "CW" "CX" "CY" "CZ"