On Mon, 2004-07-05 at 23:22, Gabor Grothendieck wrote:
Marc Schwartz MSchwartz at MedAnalytics.com writes:
the likely overhead involved in paste()ing together the rows
to create objects
I thought I would check this and it seems that in my original f1 function
its not really the
On Sun, 2004-07-04 at 19:28, Spencer Graves wrote:
I see a case where f1 gives the wrong answer:
b - array(c(a:b, a, c, b:c), dim=c(2,2))
a - b[c(1,1),]
For these two matrices, f1(a,b) == c(2,2), while f2(a,b) ==
c(2,0). If b does not contain :, e.g., if it is
Marc Schwartz MSchwartz at MedAnalytics.com writes:
row.match.count - function(m1, m2)
{
if (ncol(m1) != (ncol(m2)))
stop(Matrices must have the same number of columns)
if (typeof(m1) != (typeof(m2)))
stop(Matrices must have the same data type)
m1.l -
Marc Schwartz MSchwartz at MedAnalytics.com writes:
the likely overhead involved in paste()ing together the rows
to create objects
I thought I would check this and it seems that in my original f1 function
its not really the paste itself that's the bottleneck but applying the
paste. If we
Thanks to Gabor, Marc, and Spencer for their elegant solutions. Gabor's first
solution worked the best for me.
Best,
Ravi.
From: [EMAIL PROTECTED] on behalf of Gabor Grothendieck
Sent: Sat 7/3/2004 12:12 PM
To: [EMAIL PROTECTED]
Subject: Re: [R] counting
the best for me.
Best,
Ravi.
From: [EMAIL PROTECTED] on behalf of Gabor Grothendieck
Sent: Sat 7/3/2004 12:12 PM
To: [EMAIL PROTECTED]
Subject: Re: [R] counting the occurrences of vectors
Ravi Varadhan rvaradha at jhsph.edu writes:
Hi:
I have two matrices
Hi:
I have two matrices, A and B, where A is n x k, and B is m x k, where n m k. Is
there a computationally fast way to count the number of times each row (a k-vector) of
B occurs in A? Thanks for any suggestions.
Best,
Ravi.
[[alternative HTML version deleted]]
What have you tried? Have you considered something like the
following:
n - 4
m - 3
k - 2
A - array(1, dim=c(n, k))
B - array(1, dim=c(m,k))
BinA - rep(NA, m)
tA - t(A)
for(i in 1:m){
BinA[i] - sum(apply(B[i,]==tA, 2, sum)==k)
}
BinA
[1] 4 4 4
hope this helps. spencer graves
Ravi
On Sat, 2004-07-03 at 09:31, Ravi Varadhan wrote:
Hi:
I have two matrices, A and B, where A is n x k, and B is m x k, where
n m k. Is there a computationally fast way to count the number
of times each row (a k-vector) of B occurs in A? Thanks for any
suggestions.
Best,
Ravi.
How
Ravi Varadhan rvaradha at jhsph.edu writes:
Hi:
I have two matrices, A and B, where A is n x k, and B is m x k, where n m
k. Is there a computationally fast way to
count the number of times each row (a k-vector) of B occurs in A? Thanks
for any suggestions.
Best,
Ravi.
Here are
10 matches
Mail list logo