On Wed, May 18, 2011 at 9:49 PM, jim holtman jholt...@gmail.com wrote:
Is this what you were after:
mdat - matrix(c(1,0,1,1,1,0), nrow = 2, ncol=3, byrow=TRUE,
+ dimnames = list(c(T1, T2),
+ c(sp.1, sp.2, sp.3)))
mdat
sp.1 sp.2 sp.3
T1 1
Is this what you are looking for:
mdat3
sp.1 sp.2 sp.3 sp.4 sp.5
T110010
T210010
T311100
T410111
# create a matrix of when species first appeared
first - apply(mdat3, 2, function(x) (cumsum(x == 1) 0) + 0L)
#
Dear R help,
Apologies for the less than informative subject line. I will do my
best to describe my problem.
Consider the following matrix:
mdat - matrix(c(1,0,1,1,1,0), nrow = 2, ncol=3, byrow=TRUE,
dimnames = list(c(T1, T2),
c(sp.1, sp.2, sp.3)))
Is this what you were after:
mdat - matrix(c(1,0,1,1,1,0), nrow = 2, ncol=3, byrow=TRUE,
+ dimnames = list(c(T1, T2),
+ c(sp.1, sp.2, sp.3)))
mdat
sp.1 sp.2 sp.3
T1101
T2110
# do 'rle' on each column and see if it is
4 matches
Mail list logo