Thank you for all the help.
Can someone refer me to a function that can help with the creation of
a concurrence matrix?
I have two asymmetric vectors (C is length 217 and D is length 16063)
that contain values of 0,1,2
I want to create a matrix E (where rows are D and columns are C) that
ouputs a score where
if C and D are the same number then E has value 1
if C and D are different numbers (i.e. 0 and 1, or 2 and 1) then E has a value 0
so for example:
so if C is c(0,0,2,1,0,0)
and D is c(0,0,1,1,1,1,1,1)
E would look like:
C 0 0 2 1 0 0
D 0 1 1 0 0 0 0
0 1 1 0 0 1 1
1 0 0 0 1 0 0
1 0 0 0 1 0 0
1 0 0 0 1 0 0
1 0 0 0 1 0 0
1 0 0 0 1 0 0
1 0 0 0 1 0 0
Concurrence Matrix
3 messages · mark salsburg, Bert Gunter, (Ted Harding)
?outer Use "!=" for FUN and convert to numeric with as.numeric() if you like. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA "The business of the statistician is to catalyze the scientific learning process." - George E. P. Box
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of mark salsburg
Sent: Wednesday, August 17, 2005 10:26 AM
To: R-help at stat.math.ethz.ch
Subject: [R] Concurrence Matrix
Thank you for all the help.
Can someone refer me to a function that can help with the creation of
a concurrence matrix?
I have two asymmetric vectors (C is length 217 and D is length 16063)
that contain values of 0,1,2
I want to create a matrix E (where rows are D and columns are C) that
ouputs a score where
if C and D are the same number then E has value 1
if C and D are different numbers (i.e. 0 and 1, or 2 and 1)
then E has a value 0
so for example:
so if C is c(0,0,2,1,0,0)
and D is c(0,0,1,1,1,1,1,1)
E would look like:
C 0 0 2 1 0 0
D 0 1 1 0 0 0 0
0 1 1 0 0 1 1
1 0 0 0 1 0 0
1 0 0 0 1 0 0
1 0 0 0 1 0 0
1 0 0 0 1 0 0
1 0 0 0 1 0 0
1 0 0 0 1 0 0
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
On 17-Aug-05 mark salsburg wrote:
Thank you for all the help.
Can someone refer me to a function that can help with the creation of
a concurrence matrix?
I have two asymmetric vectors (C is length 217 and D is length 16063)
that contain values of 0,1,2
I want to create a matrix E (where rows are D and columns are C) that
ouputs a score where
if C and D are the same number then E has value 1
if C and D are different numbers (i.e. 0 and 1, or 2 and 1) then E has
a value 0
so for example:
so if C is c(0,0,2,1,0,0)
and D is c(0,0,1,1,1,1,1,1)
E would look like:
C 0 0 2 1 0 0
D 0 1 1 0 0 0 0
0 1 1 0 0 1 1
1 0 0 0 1 0 0
1 0 0 0 1 0 0
1 0 0 0 1 0 0
1 0 0 0 1 0 0
1 0 0 0 1 0 0
1 0 0 0 1 0 0
It looks as though 1*outer(D,C,"==") does what you want (and shows up that E[1,5] and E[1,6] seem to be wrong in your example, since D[1] = C[5] = 0 and D[1] = C[6] = 0). Best wishes, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 17-Aug-05 Time: 18:56:49 ------------------------------ XFMail ------------------------------