Skip to content
Prev 343107 / 398506 Next

populating matrix with binary variable after matching data from data frame

Another solution is to use table to generate your x matrix, instead of
trying to make one and adding to it.  If you want the table to have
the same dimnames on both sides, make factors out of the columns of x1
with the same factor levels in both.  E.g., using a *small* example:
V2
V1  A B C
  A 0 0 2
  B 1 0 0
  C 0 0 0

If you don't want counts, but just a TRUE for presence and FALSE for
absence, use X>0.  If you want 1 for presence and 0 for absence you
can use pmin(X, 1).

Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Wed, Aug 13, 2014 at 2:51 PM, William Dunlap <wdunlap at tibco.com> wrote: