An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121111/d782f602/attachment.pl>
Cropping a matrix by rows
2 messages · Hans Thompson, Jeff Newmiller
I assiduously avoid automatically generating distinct objects, and recommend that you also do so.
You have the data, and can refer to individual rows by index as you need them.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
Hans Thompson <hans.thompson1 at gmail.com> wrote:
Hello r-help, I've been banging my head against the computer in an attempt to learn how to divide my matrix into segments by rows. I want to be able to return each segment as a newly named object. I've tried looking at the apply functions and creating a for loop but brain no work. Here's the basic starting objects that I believe would be needed to separate the matrix. mat <- matrix(c(1:40),10,4) rowcropping <- sort(sample(2:9,2)) rowcropping <- c(1,rowcropping,length(mat[,1])) mat[rowcropping[1]:rowcropping[2],] I want something like the last line as the first object but getting them all by automation as separate objects is my goal. Thanks. [[alternative HTML version deleted]]
______________________________________________ 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.