thanks.
 
how to remove the combinations that has same ingredients:
in C, the following sentences are used.
 
for i = 1 to 3
   
 
for "a b a", "a a b" and "b a a", only one of them is kept, others are remove.
 
v<-c("a","b","c")
v v should be aa, ab, ac, bc
  

--- On Sun, 8/31/08, Lucien Lemmens <[EMAIL PROTECTED]> wrote:

From: Lucien Lemmens <[EMAIL PROTECTED]>
Subject: Re: [R] give all combinations
To: [EMAIL PROTECTED]
Date: Sunday, August 31, 2008, 8:38 AM

Yuan Jian <jayuan2008 <at> yahoo.com> writes:

> 
> Hello,
>  
> is there a simple way to give all combinations for a given vector:
>  
> v<-c("a","b","c")
>  
> combination(v,v) becomes
>
"aa","ab","ac","bb","bc","cc'
>  
> combination(v,v,v) becomes
> "aaa","aab","aac","abb",......
>  
vv<-c(outer(v,v,paste))
 vv
[1] "a a" "b a" "c a" "a b" "b
b" "c b" "a c" "b c" "c c"
vvv<-c(outer(vv,v,paste)
 vvv
 [1] "a a a" "b a a" "c a a" "a b a"
"b b a" "c b a" "a c a" "b c a" 
"c c a" "a a b" "b a b" "c a b" "a
b b" "b b b" 
"c b b"
[16] "a c b" "b c b" "c c b" "a a c"
"b a c" "c a c" 
"a b c" "b b c" "c b c" "a c c" "b
c c" "c c c"

>  
> 
>       
>       [[alternative HTML version deleted]]
> 
> 
> 
> ______________________________________________
> R-help <at> r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



      
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to