Re: [R] inverse of which()

2019-02-28 Thread Ed Siefker
rlson > Department of Anthropology > Texas A University > College Station, TX 77843-4352 > > -Original Message- > From: R-help On Behalf Of Ed Siefker > Sent: Wednesday, February 27, 2019 5:03 PM > To: r-help > Subject: [R] inverse of which() > > Give

Re: [R] inverse of which()

2019-02-27 Thread William Dunlap via R-help
The inverse of which() would have to know the length of the logical vector to create. The function could be invWhich <- function(whichTrue, length) { stopifnot(length <= max(whichTrue), !anyNA(whichTrue)) v <- logical(length) v[whichTrue] <- TRUE v } It isn't

Re: [R] inverse of which()

2019-02-27 Thread Jeff Newmiller
use grepl? On February 27, 2019 3:03:27 PM PST, Ed Siefker wrote: >Given a vector of booleans, chich() will return indices that are TRUE. > >Given a vector of indices, how can I get a vector of booleans? > >My intent is to do logical operations on the output of grep(). Maybe >there's a better

Re: [R] inverse of which()

2019-02-27 Thread David L Carlson
On Behalf Of Ed Siefker Sent: Wednesday, February 27, 2019 5:03 PM To: r-help Subject: [R] inverse of which() Given a vector of booleans, chich() will return indices that are TRUE. Given a vector of indices, how can I get a vector of booleans? My intent is to do logical operations on the output

[R] inverse of which()

2019-02-27 Thread Ed Siefker
Given a vector of booleans, chich() will return indices that are TRUE. Given a vector of indices, how can I get a vector of booleans? My intent is to do logical operations on the output of grep(). Maybe there's a better way to do this? Thanks -Ed __