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
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
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
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:
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
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
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
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
8 matches
Mail list logo