I'm trying to create a list of combinations of strings using combn()
with paste0
as the function, but all I get back is the matrix of combinations. What am I doing wrong?
Example:
combn(LETTERS[1:5],3, FUN=paste0)
Gives me:
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] "A" "A" "A" "A" "A" "A" "B" "B" "B" "C"
[2,] "B" "B" "B" "C" "C" "D" "C" "C" "D" "D"
[3,] "C" "D" "E" "D" "E" "E" "D" "E" "E" "E"
When what I expected to get was something like:
[1] "ABC" "ABD" "ABE" "ACD" "ACE" "ADE" ...
What did I miss?
Can you use this command and see if it works ? It worked for me.
combn(LETTERS[1:5],3, FUN=paste0, collapse = "")