On Sun, 6 Jun 2021 04:34:02 -0700 William Michels via R-help <r-help@r-project.org> wrote:
<SNIP> > ... But of course, a more simple approach than I previously > posted would be below (although less idiomatic than your answer): > > > object <- 1:100 > > index <- ifelse(object %% 2 == 1, TRUE, FALSE) > > object[index] > [1] 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 > 45 47 49 51 53 55 57 > [30] 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 Why faff around with ifelse()? object[object %% 2 == 1] works just fine. <SNIP> cheers, Rolf Turner -- Honorary Research Fellow Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.