[R] cbind in data.frame

2008-08-24 Thread Yuan Jian
hi,
when I used cbind to combine columns, some contents of columns has been 
replaced by
number. in the script below, column should be aaa,bbb,ccc but I was given 1,2,3.
but when I change the column to vector, it gave me correct contents. can you 
please 
tell me why?
 
> d<-read.table("aaa.txt")
> d
   V1  V2
1 aaa 123
2 bbb 345
3 ccc 986
> cbind(d[,1],d[,2])
 [,1] [,2]
[1,]    1  123
[2,]    2  345
[3,]    3  986
> cbind(as.vector(d[,1]),d[,2])
 [,1]  [,2] 
[1,] "aaa" "123"
[2,] "bbb" "345"
[3,] "ccc" "986"
> 



  
[[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.


Re: [R] cbind in data.frame

2008-08-25 Thread Yuan Jian
Thanks Charles,
 
when I use cbind.data.frame(), the column was not replaced by number.
I could not find information about cbind.data.frame. what is the machineism of 
cbind.data.frame?
 
cheers
 
Yu


--- On Mon, 8/25/08, Charles Plessy <[EMAIL PROTECTED]> wrote:

From: Charles Plessy <[EMAIL PROTECTED]>
Subject: Re: [R] cbind in data.frame
To: r-help@r-project.org
Date: Monday, August 25, 2008, 6:09 AM

Le Sun, Aug 24, 2008 at 10:56:43PM -0700, Yuan Jian a écrit :
> hi,
> when I used cbind to combine columns, some contents of columns has been
replaced by
> number. in the script below, column should be aaa,bbb,ccc but I was given
1,2,3.
> but when I change the column to vector, it gave me correct contents. can
you please 
> tell me why?
> ?
> > d<-read.table("aaa.txt")

Hello,

read.table converts characters to factors. Factors will be converted
to numbers by cbind, as in the following example:

> toto <- c("aaa","bbb","aaa")
> toto
[1] "aaa" "bbb" "aaa"
> as.factor(toto)
[1] aaa bbb aaa
Levels: aaa bbb
> cbind(as.factor(toto))
 [,1]
[1,]1
[2,]2
[3,]1

The 'as.is' or 'colClasses' option of read.table will help you
to prevent the
conversion of characters to factors.

Have a nice day,

-- 
Charles Plessy
http://charles.plessy.org
Tsurumi, Kanagawa, Japan

__
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.


[R] add to vector without duplicatation

2008-08-27 Thread Yuan Jian
Hi,
 
I try to add items to a vector, but when the it has existed, the item should be 
skipped.
does anyone know how to do it a simple way?
 
 
Yu


  
[[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.


[R] lost attrubute:names

2008-08-28 Thread Yuan Jian
Hi,
when I pick out one element from a matrix, the attribute name is kept, but when
more than one elements are extracted, the attribute name lost;
 
>a<-matrix(c(1,2,3,11,12,13,45,56,76),ncol=3,dimnames=list(c(),c("c1","c2","c3")))
> k<-a[a[,"c3"]>50,"c3"]
> kk<-a[a[,"c3"]>60,"c3"]
> attributes(k)
NULL
> attributes(kk)
$names
[1] "c3"
 
 
YU


  
[[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.


[R] remove levels from a factor

2008-08-29 Thread Yuan Jian
Hi, 
 
how to remove levels that have less than a specific number such as 2. i.e..
 
> f<-as.factor(c("a","b","a"))
> f
[1] a b a
Levels: a b

I want to remove level b because level b has less than 2.
> f
[1] a a
Levels: a

 


  
[[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.


[R] remove low frequent rows

2008-08-30 Thread Yuan Jian
Hi,
 
I have a matrix.
>a<-cbind(c("a","b","a"),c(4,3,6))
 [,1] [,2]
[1,] "a"  "4" 
[2,] "b"  "3" 
[3,] "a"  "6" 

I want to remove rows in matrix a whose first column has frequency less than 2.
in about example matrix a becomes
 [,1] [,2]
[1,] "a"  "4" 
[2,] "a"  "6" 




  
[[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.


[R] give all combinations

2008-08-31 Thread Yuan Jian
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",..
 
 


  
[[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.


Re: [R] give all combinations

2008-08-31 Thread Yuan Jian
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  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  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.


Re: [R] give all combinations

2008-08-31 Thread Yuan Jian
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  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  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.


Re: [R] give all combinations

2008-08-31 Thread Yuan Jian
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  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  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.


Re: [R] give all combinations

2008-08-31 Thread Yuan Jian
thanks.
 
how to remove the combinations that has same ingredients:
in other computer language, the following sentences are used.
 
for i = 1 to 3
    for j = 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  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  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.


Re: [R] give all combinations

2008-08-31 Thread Yuan Jian
thanks.
 
how to remove the combinations that has same ingredients:
in other computer language, the following sentences are used.
 
for i = 1 to 3
    for j = 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  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  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.


Re: [R] give all combinations

2008-08-31 Thread Yuan Jian
thanks.
 
how to remove the combinations that has same ingredients:
in other computer language, the following sentences are used.
 
for i = 1 to 3
    for j = 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  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  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.


Re: [R] give all combinations

2008-08-31 Thread Yuan Jian
thanks.
 
how to remove the combinations that has same ingredients:
in other computer language, the following sentences are used.
 
for i = 1 to 3
    for j = 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  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  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.


Re: [R] give all combinations

2008-08-31 Thread Yuan Jian
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  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  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.


Re: [R] give all combinations

2008-08-31 Thread Yuan Jian
thanks.
how to remove the combinations that has same ingredients:
v<-c("a","b","c")
v.v becomes ab, ac, bc (aa,bb,cc are removed)
v.v.v becomes abc (aaa,aab,... are removed, because they have same ingredients)
 
that is. 
the following sentences can be used.
 
for(i in 1:3){
    for (j in i+1:3){
    v.v<-c(v.v,paste(v[i],v[j]))
    }
}

 
is there simpler way to do?
thanks
Yu

--- 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  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  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.


[R] programming

2008-09-01 Thread Yuan Jian
Hi,
 
I am looking for R editor. does anyone know good editor? which tells you
syntax error and it has function to beautify format (insert TAB etc.).
 
Yu
 


  
[[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.