In R, to match a literal period in a regular expression, you would use the escape sequence ________.

  • .
  • *
  • /
  • ?
In R, to match a literal period (dot) in a regular expression, you would use the escape sequence . . For example, "abc.def" would match the string "abc.def".

How do you convert a numeric variable to a string in R?

  • as.character()
  • convert_to_string()
  • str()
  • to_string()
In R, the as.character() function is used to convert a numeric variable to a string. For example, as.character(123) would return "123".

Can variables in R hold more than one data type at a time?

  • No, variables in R can hold only one data type at a time
  • None of the above
  • Yes, if the variable is a list
  • Yes, if the variable is a vector
In R, a variable can hold more than one data type at a time if it is a list. Lists in R can contain elements of different types (e.g., numbers, strings, vectors, and other lists). However, other common R data structures, such as vectors and matrices, can hold only one data type at a time.

If you're using a for loop in R to modify the elements of a vector, it's often more efficient to first create a copy of the vector using the ______ function.

  • copy()
  • duplicate()
  • clone()
  • rep()
If you're using a for loop in R to modify the elements of a vector, it's often more efficient to first create a copy of the vector using the duplicate() function. This way, you avoid modifying the original vector during the loop, which can be costly for larger vectors.

Can you nest different types of loops in R, like for inside while and vice versa?

  • Yes, different types of loops can be nested in R
  • No, only loops of the same type can be nested
  • It depends on the R version being used
  • It depends on the operating system
Yes, different types of loops, such as for inside while and vice versa, can be nested in R. This means you can have a loop of one type inside a loop of another type, allowing for more flexible control flow and iteration.

Imagine you want to concatenate a vector of numbers into a single string. What steps would you take?

  • None of the above
  • Use the as.character() function then the paste() function
  • Use the paste() function with collapse argument
  • Use the str() function then the paste() function
To concatenate a vector of numbers into a single string, you would first need to convert the numbers into characters using the 'as.character()' function. Then, you can use the 'paste()' function with the 'collapse' argument to concatenate all the elements into a single string.

The ______ function in R can be used to explode segments in a pie chart.

  • explode()
  • pull()
  • detach()
  • All of the above
The explode() function in R can be used to explode segments in a pie chart. By specifying a vector of values, the explode() function moves specific segments away from the center of the pie chart, highlighting or separating them for emphasis.

How do you perform a logical 'AND' operation in R?

  • Using the '&' operator
  • Using the '&&' operator
  • Using the 'AND' keyword
  • All of the above
In R, you can perform a logical 'AND' operation using the '&' operator. The '&' operator returns 'TRUE' if both operands are 'TRUE', and 'FALSE' otherwise. For example, 'TRUE & FALSE' would evaluate to 'FALSE'.

The switch() function in R can be used as an alternative to multiple ________ if statements.

  • nested
  • vectorized
  • case-when
  • all
The switch() function in R can be used as an alternative to multiple nested if statements. It allows you to match a given expression to a set of predefined cases and execute the corresponding code block based on the matching case. This provides a more concise and readable alternative to using multiple nested if statements for handling multiple conditions.

In R, the escape sequence for a tab character is ________.

  • n
  • t
  • r
  • b
In R, the escape sequence for a tab character is t. For example, "HellotWorld" would result in the string "Hello World" with a tab space between "Hello" and "World".