[R] array manipulation simple questions

2009-02-23 Thread Λεωνίδας Μπαντής
  Hi there,   I am pretty new to R. Actually I started using it yesterday. I have two questions:   1.   Suppose I have a<-c(1:10)  (or a<-array(c(1:10),dim=c(1,10)))   and I want to end up with vector b=[0 0 0 0 0 1 1 1 1 1]. i.e. I want to substitute alla elements that are <5 with 0 and >5 with

Re: [R] array manipulation simple questions

2009-02-23 Thread jdeisenberg
Λεωνίδας Μπαντής wrote: > > 1. Suppose I have a<-c(1:10) (or a<-array(c(1:10),dim=c(1,10))) > > and I want to end up with vector b=[0 0 0 0 0 1 1 1 1 1]. i.e. I want to > substitute alla elements that are <5 with 0 and >5 with 1. > I think you mean >=5, not > 5. In that case, try this:

Re: [R] array manipulation simple questions

2009-02-23 Thread Gabor Grothendieck
2009/2/23 Λεωνίδας Μπαντής : > > Hi there, > > I am pretty new to R. Actually I started using it yesterday. I have two > questions: > > 1.   Suppose I have a<-c(1:10)  (or a<-array(c(1:10),dim=c(1,10))) > > and I want to end up with vector b=[0 0 0 0 0 1 1 1 1 1]. i.e. I want to > substitute alla

Re: [R] array manipulation simple questions

2009-02-23 Thread andrew
On Feb 24, 3:57 pm, jdeisenberg wrote: > Λεωνίδας Μπαντής wrote: > > > 1.   Suppose I have a<-c(1:10)  (or a<-array(c(1:10),dim=c(1,10))) > > > and I want to end up with vector b=[0 0 0 0 0 1 1 1 1 1]. i.e. I want to > > substitute alla elements that are <5 with 0 and >5 with 1. > > I think you