[R] using cut on matrices
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Sat Jul 12 12:39:48 CEST 2003
Tamas Papp <tpapp at axelero.hu> writes:
> Dear list,
>
> I'd like to use the function cut() on matrices, ie that when I apply
> it to a matrix, it would return a matrix of the same dimensions
> instead of a vector.
>
> I wonder if there is a better (more elegant) solution than
>
> matrix(cut(a, ...), ncol=ncol(a), nrow=nrow(a))
>
> because I would like to use cut on both vectors and matrices and avoid
> testing whether a is a matrix.
Will this not work?:
ac <- cut(a)
dim(ac) <- dim(a)
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list