s-news
[Top] [All Lists]

More elegant usage of outer?

To: <s-news@lists.biostat.wustl.edu>
Subject: More elegant usage of outer?
From: "Steve Su" <s.su@qut.edu.au>
Date: Fri, 24 Sep 2004 12:13:21 +1000
Dear All,

I am trying to write a nice and elegant function in Splus 6.0 on Windows XP.
Basically what I am trying to do is this:

list1<-1:3
list2<-4:7
list3<-9:12
list4<-0:2

# If I only have list1 and list2
outer(list1,list2,"paste")
# If I have list1, list2 and list3
outer(outer(list1,list2,"paste"),list3,"paste")
# If I have list1, list2, list3 and list4
outer(outer(outer(list1,list2,"paste"),list3,"paste"),list4,"paste")
# And so forth.....

I am thinking there must be a more elegant solution instead of using outer
recursively? It does not matter if the final output is a matrix or array as
long as I can get all the combinations right. I seem to be rather blind at
the moment to see a better solution than the above!

Thank you for your attention.

Steve.


















****************************************************************************
**********

 Steve Su (s.su@qut.edu.au)
 Postdoctoral fellow

 School of Accountancy
 Queensland University of Technology

 Postal Address: Steve Su, School of Accountancy, QUT, PO Box 2434,
Brisbane,
 Queensland, Australia, 4001.

 Phone:  +61 7 3864 4357
 Fax:    +61 7 3864 1812
 Mobile: 0421  840  586
     .
   _--_|\
  /      QUT
  \_.--._/
        v

****************************************************************************
**********


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