Knowledge Quiz: Basic Commands

Note
  • Click the check-mark button to check your answer.
  • Click the question-mark button to see an explanation of the solution.

Which of the following commands represents the recommended way to assign the value 7 to the object y?

Although there are three valid assignment operators: <-, ->, =, only the left-facing arrow is recommended by most style guides.

  • This is a misuse of the native R pipe operator.
  • This command adds the value of y to the value of 7 and prints the result.
  • This is technically valid assignment, but putting the variable on the right-hand side of the assignment operator is not recommended style.
  • Correct
  • This isn’t legal R code. This command attempts to assign the value y to the variable 7, but variable names can’t begin with numbers.

What value will the following R code produce?

(2 + 4) * 3 - 8

By applying the appropriate order of operations, we get 10.

Which of the following expressions will return TRUE?

  • FALSE: “alice” is not equal to “bob”
  • TRUE: Trivially
  • FALSE: “alice” is not equal to “bob”, and “alice” is equal to “alice”
  • FALSE: Trivially
  • FALSE: Trivial negation
  • FALSE: Trivially
Back to top