[R] create a pairwise coocurrence matrix
Michael Bedward
michael.bedward at gmail.com
Fri Nov 12 02:19:38 CET 2010
On 12 November 2010 02:21, David Winsemius <dwinsemius at comcast.net> wrote:
>
>> The fastest and easiest solution is
>>
>> t(A) %*% A
>
> That is really elegant. (Wish I could remember my linear algebra lessons as
> well from forty years ago.) I checked it against the specified output and
> found that with one exception that the OP had planned for the diagonal to be
> filled with zeroes. So that could be completed by a simple modification:
>
> temp <- t(A) %*% A
> diag(temp) <- 0
> temp
>
Excellent solution ! Small is beautiful :)
Michael
More information about the R-help
mailing list