Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在R中生成AA、AB、AC…、BA、BB、BC…、CA、CB、CC…、ZZ系列?_R_Combinations - Fatal编程技术网

如何在R中生成AA、AB、AC…、BA、BB、BC…、CA、CB、CC…、ZZ系列?

如何在R中生成AA、AB、AC…、BA、BB、BC…、CA、CB、CC…、ZZ系列?,r,combinations,R,Combinations,我必须生成一个字母表系列(AA、AB、AC…、BA、BB、BC…、CA、CB、CC…、ZZ),类似于excel文件的默认列名 我用下面的组合函数进行了尝试 combn(LETTERS,2) 但是,这与我的要求不符。另一种选择是外部 as.vector(sapply(LETTERS,function(x) sapply(LETTERS , function(y) paste0(x,y)))) out <- c(outer(LETTERS, LETTERS, paste0)) head(s

我必须生成一个字母表系列(AA、AB、AC…、BA、BB、BC…、CA、CB、CC…、ZZ),类似于excel文件的默认列名

我用下面的组合函数进行了尝试

combn(LETTERS,2)

但是,这与我的要求不符。

另一种选择是
外部

as.vector(sapply(LETTERS,function(x) sapply(LETTERS , function(y) paste0(x,y))))
out <- c(outer(LETTERS, LETTERS, paste0))
head(sort(out))
# [1] "AA" "AB" "AC" "AD" "AE" "AF"

out Try
do.call(粘贴0,展开.grid(rep(list(LETTERS),2))[2:1])
使用此功能,您还可以为n=3生成,即
do.call(粘贴0,展开.grid(rep(list(LETTERS),3))
及以上版本`@akrun非常感谢。这就是我一直在寻找的:)很好的答案。检查格式。