DomDom
2010-Nov-04 21:46 UTC
[R] creating vectors with three variables out of three datasets
Hi there, i´ve got a problem with how to create a vector with three variables out of three seperate ascii files. These three ascii files contain pixel information of the same image but different bands and i need a matrix of vectors, with each vector containing the corresponding pixel values for each band. Up to now i´ve seperately read out the ascii files into three matrices but don´t know how to put the corresponding pixel values together. Looking forward to any help. Thank you Dominik -- View this message in context: http://r.789695.n4.nabble.com/creating-vectors-with-three-variables-out-of-three-datasets-tp3027852p3027852.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]]
Erik Iverson
2010-Nov-04 21:50 UTC
[R] creating vectors with three variables out of three datasets
DomDom wrote:> Hi there, > > i??ve got a problem with how to create a vector with three variables out of > three seperate ascii files. > These three ascii files contain pixel information of the same image but > different bands and i need a matrix of > vectors, with each vector containing the corresponding pixel values for each > band. > > Up to now i??ve seperately read out the ascii files into three matrices but > don??t know how to put the corresponding pixel values together.Perhaps rbind or cbind, see ?rbind. It would be useful if you gave us a small, reproducible example of the type of data you have and what you want to do with it, please see the Posting Guide.> > Looking forward to any help. > Thank you > > Dominik > > > > > ------------------------------------------------------------------------ > > ______________________________________________ > 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.
DomDom
2010-Nov-04 22:05 UTC
[R] creating vectors with three variables out of three datasets
okay sorry. i?ve got three ascii files with pixel values without any header information. so if the first line of the three ascii files are: ascii1: 11 12 13 ascii2: 14 15 16 ascii3: 17 18 19 i would like a new matrix with: 11,14,17;12,15,18;13,16,19; thx -- View this message in context: http://r.789695.n4.nabble.com/creating-vectors-with-three-variables-out-of-three-datasets-tp3027852p3027880.html Sent from the R help mailing list archive at Nabble.com.
jim holtman
2010-Nov-05 00:02 UTC
[R] creating vectors with three variables out of three datasets
Is this what you want:> xV1 V2 V3 V4 1 ascii1: 11 12 13 2 ascii2: 14 15 16 3 ascii3: 17 18 19> z <- as.matrix(x[,-1]) > zV2 V3 V4 [1,] 11 12 13 [2,] 14 15 16 [3,] 17 18 19> as.vector(z)[1] 11 14 17 12 15 18 13 16 19>On Thu, Nov 4, 2010 at 6:05 PM, DomDom <realownage at msn.com> wrote:> > okay sorry. > i?ve got three ascii files with pixel values without any header information. > > so if the first line of the three ascii files are: > > ascii1: 11 12 13 > ascii2: 14 15 16 > ascii3: 17 18 19 > > i would like a new matrix with: > 11,14,17;12,15,18;13,16,19; > > thx > > > -- > View this message in context: http://r.789695.n4.nabble.com/creating-vectors-with-three-variables-out-of-three-datasets-tp3027852p3027880.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?