Re: [R] modifying patterns in a matrix

2008-09-17 Thread David Winsemius
On Sep 17, 2008, at 3:50 PM, Stacey Burrows wrote: Dear R-users, I have some very simple data where 1's represent events and zeroes non-events, e.g. temp <- rbind(c(0,1,0,0,1,1,1,0), c(0,0,0,1,0,0,0,0)) For each row in the matrix, I would like to replace a singelton event by a 0. That is

Re: [R] modifying patterns in a matrix

2008-09-17 Thread Henrique Dallazuanna
Try this: do.call(rbind, strsplit(gsub("010", "000", apply(temp, 1, paste, collapse = "")), NULL)) On Wed, Sep 17, 2008 at 4:50 PM, Stacey Burrows <[EMAIL PROTECTED]>wrote: > Dear R-users, > > I have some very simple data where 1's represent events and zeroes > non-events, e.g. > temp <- rbind(c