David Orme imperial.ac.uk> writes:
:
: >
: > outer() generally works by expanding out the lists like
: >
: > Y <- rep(y,length(x))
: > X <- rep(x,each=length(y)) # or maybe it's vice versa, never mind...
: > FUN(X,Y,extras)
: >
: > and then adds dims and dimnames. If FUN vectorizes, this is the
outer() generally works by expanding out the lists like
Y <- rep(y,length(x))
X <- rep(x,each=length(y)) # or maybe it's vice versa, never mind...
FUN(X,Y,extras)
and then adds dims and dimnames. If FUN vectorizes, this is the
efficient way, but it does not in your case and the rep()s are
probably
David Orme <[EMAIL PROTECTED]> writes:
> Following up on Peter Dalgaard's suggestion, I've tried vectorizing
> the function properly. Now I get the same answers from both the two
> for() loops and the vectorized outer() call. What puzzles me slightly
> is that using outer is about 13 times slower.
On 10 May 2004, at 15:45, Jason Turner wrote:
I'm having a hard time figuring out what you want. Who is this mystery
object "test"?
Ah - sorry all. That should be:
for(x in ind){
for(y in ind){
result[x,y] <- sum(mylist[[x]][mylist[[x]] %in% mylist[[y]]])
}
}
As a style point, ind <-
"David Orme" <[EMAIL PROTECTED]> wrote:
...
> I'm have a list of integer vectors and I want to perform an outer()
> like operation on the list. As an example, take the following list:
>
> mylist <- list(1:5,3:9,8:12)
>
> A simple example of the kind of thing I want to do is to find the sum
> of the
David Orme <[EMAIL PROTECTED]> writes:
> Hi,
>
> I'm have a list of integer vectors and I want to perform an outer()
> like operation on the list. As an example, take the following list:
>
> mylist <- list(1:5,3:9,8:12)
>
> A simple example of the kind of thing I want to do is to find the sum
>
Hi,
I'm have a list of integer vectors and I want to perform an outer()
like operation on the list. As an example, take the following list:
mylist <- list(1:5,3:9,8:12)
A simple example of the kind of thing I want to do is to find the sum
of the shared numbers between each vector to give a res