R Operators MCQ

1. What does the '==' operator do in R?

a) Assignment
b) Multiplication
c) Equality test
d) Increment

Answer:

c) Equality test

Explanation:

The '==' operator in R is used for testing equality between two values or expressions.

2. Which operator is used for matrix multiplication in R?

a) *
b) %*%
c) x
d) &

Answer:

b) %*%

Explanation:

In R, the '%*%' operator is used for matrix multiplication, performing the dot product of two matrices.

3. How do you assign a value to a variable in R?

a) :=
b) ==
c) =
d) <-

Answer:

d) <-

Explanation:

The '<-' operator is commonly used for assignment in R. The '=' operator can also be used, but '<-' is more traditional in R.

4. What is the purpose of the '!' operator in R?

a) Addition
b) Negation
c) Concatenation
d) Division

Answer:

b) Negation

Explanation:

The '!' operator is the logical NOT operator in R, used to negate a logical value.

5. Which operator is used for integer division in R?

a) /
b) //
c) %/%
d) %%

Answer:

c) %/%

Explanation:

The '%/%' operator in R performs integer division, which gives the quotient of the division without the remainder.

6. How is the modulo operation performed in R?

a) mod()
b) %
c) /%
d) %%

Answer:

d) %%

Explanation:

The '%%' operator in R is used to perform the modulo operation, returning the remainder of a division.

7. What does the '&&' operator do in R?

a) Bitwise AND
b) Logical AND
c) Element-wise logical AND
d) String concatenation

Answer:

b) Logical AND

Explanation:

The '&&' operator in R performs a logical AND operation between two logical expressions.

8. What is the use of the '|' operator in R?

a) Logical OR
b) Bitwise OR
c) Element-wise logical OR
d) String concatenation

Answer:

a) Logical OR

Explanation:

The '|' operator is used for performing a logical OR operation in R.

9. Which operator is used to raise a number to the power of another number in R?

a) ^
b) **
c) %
d) &

Answer:

a) ^

Explanation:

The '^' operator in R is used for exponentiation, raising a number to the power of another number.

10. How do you check for inequality in R?

a) !=
b) <>
c) ~=
d) =!

Answer:

a) !=

Explanation:

The '!=' operator is used to check for inequality between two values or expressions in R.

11. What is the result of the expression 'TRUE & FALSE' in R?

a) TRUE
b) FALSE
c) NULL
d) NA

Answer:

b) FALSE

Explanation:

The '&' operator performs a logical AND, so 'TRUE & FALSE' evaluates to FALSE.

12. What is the effect of the '<-' operator inside a function call in R?

a) Global assignment
b) Local assignment
c) Equality test
d) Reference passing

Answer:

b) Local assignment

Explanation:

The '<-' operator inside a function call in R assigns a value to a variable locally within the function's scope.

13. What does the '%%' operator return when used with positive numbers in R?

a) The quotient
b) The product
c) The difference
d) The remainder

Answer:

d) The remainder

Explanation:

The '%%' operator in R returns the remainder of the division between two numbers.

14. Which operator in R is used for element-wise multiplication in vectors?

a) *
b) x
c) %*%
d) &

Answer:

a) *

Explanation:

The '*' operator in R performs element-wise multiplication when used with vectors.

15. What does the '->' operator do in R?

a) Right to left assignment
b) Left to right assignment
c) Equality check
d) Comparison

Answer:

a) Right to left assignment

Explanation:

The '->' operator in R assigns the value on its left to the variable on its right, opposite to the more common '<-' operator.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top