Exercise 4-6

  • cumsum(x) and cumsum(!x) can be used to test if any ‘x’ is TRUE or FALSE

  • cumprod(x) and cumprod(!x) can be used to test if any ‘x’ is TRUE or FALSE

  • In each case, the logical elements are automatically coerced into zeroes and ones.

  • Does this use of cumsum(), etc. have any practical use vs. using isTrue(x) or TRUE %in% x, etc?