Exercise 4-6

  • c(TRUE, FALSE)*1:10 is equal to c(0,1)*1:10
  • sum(as.logical(x)) computes the number of non-zero elements in the vector.
  • No, for instance as.numeric(as.character(FALSE)) returns a different value than as.numeric(FALSE).