s-news
[Top] [All Lists]

Re2: [splus-users,11557] [S] Combinatory function

To: s-news@wubios.wustl.edu
Subject: Re2: [splus-users,11557] [S] Combinatory function
From: TAKEZAWA Kunio <takezawa@affrc.go.jp>
Date: Wed, 23 Jun 1999 09:01:04 +0900
In-reply-to: <199906221414.XAA25328@cabbage.math.keio.ac.jp>
Sender: owner-s-news@wubios.wustl.edu
E-mail: s-news@wubios.wustl.edu

Hi!

>dd1<-seq(from=1, by=1, length=5)
>comb <- expand.grid(x1 =dd1 , x2 =dd1, x3 =dd1, x4 = dd1, x5=dd1,
>xx6=dd1)
>This program gives you all combinations of c(1,2,3,4,5).
>If you replace "1" by "a", "2" by "b",-----, "5" by "e",
>it results in all combinations of a,b,c,d,e.


   Program like below may be simpler; you do not have
to replace numbers by letters :

function()
{
        dd1 <- c("a", "b")
        comb <- expand.grid(x1 = dd1, x2 = dd1, x3 = dd1)
        print(comb)
}


Result is :

  x1 x2 x3 
1  a  a  a
2  b  a  a
3  a  b  a
4  b  b  a
5  a  a  b
6  b  a  b
7  a  b  b
8  b  b  b

K. Takezawa

   *****    Kunio Takezawa, Ph.D. (takezawa@affrc.go.jp)    *****
  *****            Research Information Section              *****
 **** Hokuriku National Agricultural Experiment Station, JAPAN ****
*****     <http://www.inada.affrc.go.jp/~takezawa/patent-e.html>    *****
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

<Prev in Thread] Current Thread [Next in Thread>