[R] question on maximum of each row of the matrix
dwinsemius at comcast.net
Fri Mar 5 14:47:54 CET 2010
On Mar 5, 2010, at 7:30 AM, khazaei at ceremade.dauphine.fr wrote:
> I used the apply()function to compute the maximum of the each row
> the matrix, but in my application sometime the matrix has just one
> and the apply() dosen't work.
> Could you please give me some hints?
If your matrix became a one row entity as a result of an indexing or
subsetting operation, then you could prevent the loss of its matrix
classification by using the drop=FALSE argument.
> strt <- matrix(1:8, ncol=2)
> strt[ , 2, drop=FALSE]
> apply(strt[ , 2, drop=FALSE], 1, max)
 5 6 7 8
> thank you
David Winsemius, MD
West Hartford, CT
More information about the R-help