On Mon, Jan 16, 2012 at 10:15 AM, Duncan Murdoch
wrote:
> On 12-01-16 10:34 AM, Marion Wenty wrote:
>>
>> Dear People,
>>
>> I have got the following example for a vector and the index of the TRUE
>> element:
>>
>> Myvector<- c(FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE)
>> which(Myvector)
>>
>
> Thank you all very much for your help!
>
Yes, the unlist or as.logical command is what I was looking for.
Anyway, Duncan, the sapply is also usefull and I might need it some other
time.
Thanks, Michael, also for the tip that if you get a vector when a list is
expected,
that the the program w
Given
Mylist <- list(FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE)
Try
which(as.logical(MyList))
to return the indices where Mylist is TRUE.
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mai
On 12-01-16 10:34 AM, Marion Wenty wrote:
Dear People,
I have got the following example for a vector and the index of the TRUE
element:
Myvector<- c(FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE)
which(Myvector)
Now I would like to find out the same for a list:
Mylist<- list(FALSE,FALSE,FALS
I'd just unlist it to a vector and use the same methods: a plus of
this (I believe) is that if you get a vector when a list as expected,
your program will continue to work.
Michael
On Mon, Jan 16, 2012 at 10:34 AM, Marion Wenty wrote:
> Dear People,
>
> I have got the following example for a vec
On Jan 16, 2012, at 10:34 AM, Marion Wenty wrote:
Dear People,
I have got the following example for a vector and the index of the
TRUE
element:
Myvector <- c(FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE)
which(Myvector)
Now I would like to find out the same for a list:
Mylist <- list(F
Dear People,
I have got the following example for a vector and the index of the TRUE
element:
Myvector <- c(FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE)
which(Myvector)
Now I would like to find out the same for a list:
Mylist <- list(FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE)
...
Does
7 matches
Mail list logo