[R] How to subset a portion of columns from a matrix

affy snp affysnp at gmail.com
Sat Nov 10 05:39:42 CET 2007


Thanks!

Allen

On Nov 9, 2007 11:34 PM, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:
> Or perhaps:
>
> A[, seq(1, ncol(A), 2)]
>
>
> On Nov 9, 2007 11:25 PM, Julian Burgos <jmburgos at u.washington.edu> wrote:
> > No problem.  Actually, I missed a comma.  You should do
> >
> > A[,seq(1,dim(A)[2],2)]
> >
> > Julian
> >
> >
> >
> > affy snp wrote:
> > > Hi Julian,
> > >
> > > Thanks for the help!
> > >
> > > Best,
> > >       Allen
> > >
> > >
> > >
> > > On Nov 9, 2007 11:08 PM, Julian Burgos <jmburgos at u.washington.edu> wrote:
> > >
> > >> There are many ways. For example, you can do something like
> > >>
> > >> A[seq(1,dim(A)[2],2)]
> > >>
> > >> Julian
> > >>
> > >> Julian M. Burgos
> > >>
> > >> Fisheries Acoustics Research Lab
> > >> School of Aquatic and Fishery Science
> > >> University of Washington
> > >>
> > >> 1122 NE Boat Street
> > >> Seattle, WA  98105
> > >>
> > >> Phone: 206-221-6864
> > >>
> > >>
> > >>
> > >>
> > >> affy snp wrote:
> > >>
> > >>> Dear List,
> > >>>
> > >>> Hi! I am wondering what is the simplest way to subset a portion of columns
> > >>> from a matrix.
> > >>>
> > >>> For example, there is a matrix A (238,304*243). What is the simplest
> > >>> way to get a sub-matrix B which comprises of column 1, 3, 5, 7,9,...(odd column
> > >>> number) from matrix A?
> > >>>
> > >>> Thank you very much for your help!
> > >>>
> > >>> Best,
> > >>>      Allen
> > >>>
> > >>> ______________________________________________
> > >>> R-help at r-project.org mailing list
> > >>> https://stat.ethz.ch/mailman/listinfo/r-help
> > >>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > >>> and provide commented, minimal, self-contained, reproducible code.
> > >>>
> > >>>
> > >>
> > >>
> > >>
> >
> > --
> > Julian M. Burgos
> >
> > Fisheries Acoustics Research Lab
> > School of Aquatic and Fishery Science
> > University of Washington
> >
> > 1122 NE Boat Street
> > Seattle, WA  98105
> >
> > Phone: 206-221-6864
> >
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>



More information about the R-help mailing list