[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 1.  

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: b -

Re: [R] array manipulation simple questions

2009-02-23 Thread Gabor Grothendieck
2009/2/23 Λεωνίδας Μπαντής bleonida...@yahoo.gr: 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

Re: [R] array manipulation simple questions

2009-02-23 Thread andrew
On Feb 24, 3:57 pm, jdeisenberg catc...@catcode.com 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