Re: [R] logical 'or' on list of vectors

From: Tim Bergsma <timb_at_metrumrg.com>
Date: Fri, 08 Jun 2007 10:08:50 -0400

Thanks all for the many excellent suggestions!

!complete.cases(Theoph) is probably the most succinct form for the current problem, while the examples with 'any' seem readily adaptable to similar situations.

Kind regards,

Tim.

Dimitris Rizopoulos wrote:
> try the following:
>
> as.logical(rowSums(is.na(Theoph)))
> ## or
> !complete.cases(Theoph)
>
>
> I hope it helps.
>
> Best,
> Dimitris
>
> ----
> Dimitris Rizopoulos
> Ph.D. Student
> Biostatistical Centre
> School of Public Health
> Catholic University of Leuven
>
> Address: Kapucijnenvoer 35, Leuven, Belgium
> Tel: +32/(0)16/336899
> Fax: +32/(0)16/337015
> Web: http://med.kuleuven.be/biostat/
> http://www.student.kuleuven.be/~m0390867/dimitris.htm
>
>
> ----- Original Message ----- From: "Tim Bergsma" <timb_at_metrumrg.com>
> To: <r-help_at_stat.math.ethz.ch>
> Sent: Friday, June 08, 2007 2:57 PM
> Subject: [R] logical 'or' on list of vectors
>
>

>> Suppose I have a list of logicals, such as returned by lapply:
>>
>> Theoph$Dose[1] <- NA
>> Theoph$Time[2] <- NA
>> Theoph$conc[3] <- NA
>> lapply(Theoph,is.na)
>>
>> Is there a direct way to execute logical "or" across all vectors? The
>> following gives the desired result, but seems unnecessarily complex.
>>
>> as.logical(apply(do.call("rbind",lapply(Theoph,is.na)),2,"sum"))
>>
>> Regards,
>>
>> Tim
>>
>> ______________________________________________
>> R-help_at_stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide 
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>

>
>
> Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
>
>
>

R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 08 Jun 2007 - 14:18:07 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 08 Jun 2007 - 14:31:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.