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.

In R, the result of the operation 'TRUE AND NA' is ________.

  • TRUE
  • FALSE
  • NA
  • Error
In R, the result of the operation 'TRUE AND NA' is NA. When one of the operands in a logical operation is NA, the result is also NA because the logical value is undefined.

Can you import CSV data into R?

  • Yes, using the read.csv() function
  • No, R does not support importing CSV data
  • Yes, but it requires writing a custom function
  • Yes, using the import.csv() function
Yes, you can import CSV data into R using the read.csv() function. The read.csv() function is a built-in function in R that allows you to read CSV files and create a data frame containing the data.

Can you describe a situation where you had to use a nested if statement in R and how you ensured the code remained clear and maintainable?

  • Provide a specific scenario where nested if statements were required and describe steps taken to ensure clarity and maintainability
  • Provide a general explanation of how nested if statements can be clear and maintainable
  • There is no need to ensure clarity and maintainability with nested if statements
  • All of the above
In a situation where nested if statements were required in R, steps taken to ensure clarity and maintainability may include proper indentation, adding comments, breaking down complex conditions into smaller parts, and organizing the code logic. These practices improve code readability, understandability, and maintainability, making it easier for others to comprehend and modify the code if needed.

What is an array in R?

  • A one-dimensional data structure
  • A two-dimensional data structure with rows and columns
  • A three-dimensional data structure with multiple dimensions
  • A collection of elements of the same data type organized in multiple dimensions
In R, an array is a collection of elements of the same data type organized in multiple dimensions. It can have one, two, or more dimensions, allowing for the representation of data in higher-dimensional structures. Arrays provide a way to store and manipulate structured data that cannot be easily represented as a matrix or a vector.

The ________ function in R helps to print a more human-readable version of complex objects.

  • cat()
  • print()
  • str()
  • summary()
The str() function in R provides a compact, human-readable description of any R object, making it easier to understand the structure and content of complex objects.

In R, a function that calls itself within its own definition is known as a ________ function.

  • Recursive
  • Nested
  • Iterative
  • Repeating
In R, a function that calls itself within its own definition is known as a recursive function. Recursive functions are defined in a way that allows them to break down a complex problem into smaller sub-problems of the same type, eventually reaching a base case where the recursion stops. This self-referential behavior is a key characteristic of recursive functions.

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.