Re: [R] prblem with NA

2009-01-06 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 06.01.2009 10:02:12: > On Tue, 6 Jan 2009, Petr PIKAL wrote: > > [...] > > > Logical vectors can be treated like numeric with TRUE=1 and FALSE=0, > > More accurately, 'like integer' ('numeric' often means 'double'). > > > I learned that somewhere but

Re: [R] prblem with NA

2009-01-06 Thread Wacek Kusnierczyk
Wacek Kusnierczyk wrote: > Prof Brian Ripley wrote: > >> On Tue, 6 Jan 2009, Petr PIKAL wrote: >> >> [...] >> >> >>> Logical vectors can be treated like numeric with TRUE=1 and FALSE=0, >>> >> More accurately, 'like integer' ('numeric' often means 'double'). >> >> > > why would

Re: [R] prblem with NA

2009-01-06 Thread Wacek Kusnierczyk
Prof Brian Ripley wrote: > On Tue, 6 Jan 2009, Petr PIKAL wrote: > > [...] > >> Logical vectors can be treated like numeric with TRUE=1 and FALSE=0, > > More accurately, 'like integer' ('numeric' often means 'double'). > why would this be more accurate? is(TRUE+0) # numeric, not integer is.integ

Re: [R] prblem with NA

2009-01-06 Thread Prof Brian Ripley
On Tue, 6 Jan 2009, Petr PIKAL wrote: [...] Logical vectors can be treated like numeric with TRUE=1 and FALSE=0, More accurately, 'like integer' ('numeric' often means 'double'). I learned that somewhere but it is not mentioned in help page for ?logical so it is not so easy to find. Hmm:

Re: [R] prblem with NA

2009-01-06 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 06.01.2009 02:29:18: > Hello - > > kayj wrote: > > > > Hi all > > > > I have a data set with the total number of columns =ncol, and the total > > number of rows=nrow. I am trying to loop over the values and id the value is > > less than or equal to

Re: [R] prblem with NA

2009-01-05 Thread Erik Iverson
Hello - kayj wrote: Hi all I have a data set with the total number of columns =ncol, and the total number of rows=nrow. I am trying to loop over the values and id the value is less than or equal to 100 to be changed to 1. if the value is greater than 100 , to be changed to 0. if NA , let X[i,j

Re: [R] prblem with NA

2009-01-05 Thread jim holtman
Try vectorizing instead of a loop: > da <- matrix(nrow=10,ncol=10) > n <- sample(1:100, 40) > da[n[1:20]] <- 99 > da[n[21:40]] <- 199 > X <- ifelse(is.na(da), NA, ifelse(da <= 100, 1, 0)) > > > X [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] NA NA NA NA NA1 NA NA

[R] prblem with NA

2009-01-05 Thread kayj
Hi all I have a data set with the total number of columns =ncol, and the total number of rows=nrow. I am trying to loop over the values and id the value is less than or equal to 100 to be changed to 1. if the value is greater than 100 , to be changed to 0. if NA , let X[i,j]=NA. I ran into a pro