Seems irrelevant to me. You can export the data to separate files directly from the matrix using matrix indexing. i.e.
for (i in 1:2) { write.table( mat[rowcropping[2*i-1]:rowcropping[2*i],],paste0("file",i,".dat") } Please use reply to all to keep the discussion on the list. --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnew...@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.thomps...@gmail.com> wrote: >I am working with matrices that represent images. I believe its >important >to create them as new objects because what I would like to export these >cropped images as new files. Sorry if I didn't include that if it as >important information. > > >On Sun, Nov 11, 2012 at 1:36 PM, Jeff Newmiller ><jdnew...@dcn.davis.ca.us>wrote: > >> 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:<jdnew...@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.thomps...@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@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. >> >> ______________________________________________ R-help@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.