[R] How to index the occasions in a vector repeatedly under condition 1? if not, it will give a new index.

peter dalgaard pd@|gd @end|ng |rom gm@||@com
Fri Feb 21 10:46:16 CET 2020

It has isTRUE, but that is not vectorized, and in fact explicitly tests length==1, so

> isTRUE(c(TRUE,TRUE, TRUE)) # I thought I thaw a puddycat... ;-)
 [1] FALSE
> Vectorize(isTRUE)(c(TRUE,FALSE,NA))

(The latter would be silly as an implementation of is_true, of course.)


> On 20 Feb 2020, at 04:20 , Lijun Zhao <lijun.zhao using adelaide.edu.au> wrote:
> Some packages have the equivalent of that is_true function, which maps FALSE and NA to FALSE and TRUE to TRUE.  I don't think core R contains such a function.

Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd.mes using cbs.dk  Priv: PDalgd using gmail.com

More information about the R-help mailing list