Appendix B — Operators

B.1 Assignment:

  • <- (assignment operator)

B.2 Arithmetic:

  • + (addition)
  • - (subtraction)
  • * (multiplication)
  • / (division)
  • ^ or ** (exponentiation)
  • %% (modulo, remainder)
  • %/% (integer division)

B.3 Relational:

  • < (less than)
  • > (greater than)
  • <= (less than or equal to)
  • >= (greater than or equal to)
  • == (equal to)
  • != or <> (not equal to)

B.4 Logical:

  • & (element-wise AND)
  • | (element-wise OR)
  • ! (logical NOT)
  • && (scalar AND)
  • || (scalar OR)

B.5 Others:

  • %*% (matrix multiplication)
  • %in% (checks if an element is in a vector)
  • %>% or |> (pipe operator from the magrittr package)
  • []: Extract content from vectors, lists, or data frames.
  • [[ ]] and $: Extract a single item from an object.