[R] Splitting an array into two - alternate columns
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Thu Nov 23 15:00:11 CET 2000
Phil Rhoades <philr at mail.austasia.net> writes:
> I want to split an array (A1) into two arrays using alternate columns eg
>
> A2 would consist of:
>
> A1[,1], A1[,3], A1[,5], . .
>
> A3 would consist of:
>
> A1[,2], A1[,4], A1[,6], . .
>
> Anyone got a nice method?
How about
k <- ncol(A1)
A2 <- A1[,seq(1,k,2)]
A3 <- A1[,seq(2,k,2)]
--
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
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list