Re: [R] Creating a Matrix from a vector with some conditions

2011-01-09 Thread baptiste auguie
Hi, embed() seemed well-suited, but I couldn't figure out an elegant way to use it embed(c(A,A), 4)[1:4, 4:1] HTH, baptiste On 6 January 2011 22:34, ADias wrote: > > Hi > > Suppose we have an object with strings: > > A<-c("a","b","c","d") > > Now I do: > > B<-matrix(A,4,4, byrow=F) > > and I

Re: [R] Creating a Matrix from a vector with some conditions

2011-01-08 Thread Petr Savicky
On Thu, Jan 06, 2011 at 01:34:31PM -0800, ADias wrote: > > Hi > > Suppose we have an object with strings: > > A<-c("a","b","c","d") > > Now I do: > > B<-matrix(A,4,4, byrow=F) > > and I get > > a a a a > b b b b > c c c c > d d d d > > But what I really want is: > > a b c d > b c d a > c d

Re: [R] Creating a Matrix from a vector with some conditions

2011-01-07 Thread Petr Savicky
On Thu, Jan 06, 2011 at 01:34:31PM -0800, ADias wrote: > > Hi > > Suppose we have an object with strings: > > A<-c("a","b","c","d") > > Now I do: > > B<-matrix(A,4,4, byrow=F) > > and I get > > a a a a > b b b b > c c c c > d d d d > > But what I really want is: > > a b c d > b c d a > c d

Re: [R] Creating a Matrix from a vector with some conditions

2011-01-06 Thread David Winsemius
On Jan 6, 2011, at 4:34 PM, ADias wrote: Hi Suppose we have an object with strings: A<-c("a","b","c","d") Now I do: B<-matrix(A,4,4, byrow=F) and I get a a a a b b b b c c c c d d d d But what I really want is: a b c d b c d a c d a b d a b c How can I do this? How else? B<-matrix(A