> This seems to work: > > apply(mat1,1,function(x){paste(x,collapse="")}) > > The collapse command inside of paste is (I think) the easiest way to > combine strings. > > Michael Weylandt > > > On Thu, Aug 4, 2011 at 5:45 PM, Wegan, Michael (DNRE) <weg...@michigan.gov > > wrote: > >> I have a matrix of 5 columns and 64 rows, let's call it "mat1". All >> values are 1 or 0. I need to take the values of the elements by row and >> create a single numeric element that can be placed its respective slot in a >> 64-element list, named "list1". For example, mat1[11,1:5] = 0,1,1,0,1 and I >> must put 01101, with a length of 1, into the 11th element of list1. I can >> create the code for an iterative process, but am having a great deal of >> difficulty in figuring out how to create a single element from the row >> values, especially when the first value is 0, as in my example. >> >> >> Thanks in advance. >> >> [[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. >> > >
[[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.