In R, a list is created using the ______ function.

  • list()
  • c()
  • vector()
  • array()
In R, a list is created using the list() function. The list() function allows you to create a list by passing individual elements separated by commas or by using named arguments to assign names to the elements.

Which data type in R is used to store numeric values?

  • Character
  • Complex
  • Integer
  • Numeric
Numeric is the data type in R that is used to store both integers and decimal values. Other data types, like Integer, Complex, and Character serve different purposes.

If you have a long series of conditions to check in R, you might consider using the ______ function for a more concise syntax.

  • case_when
  • ifelse
  • switch
  • any
If you have a long series of conditions to check in R, you might consider using the case_when() function for a more concise syntax. The case_when() function in the dplyr package allows you to specify multiple conditions and their corresponding outcomes in a single line of code, making it easier to manage and understand complex conditionals.

Can you describe a situation where you used the ifelse() function for efficient vectorized operations in R?

  • When you need to apply a conditional operation to an entire vector or data frame
  • When you want to check if a condition is true for any element of a vector
  • When you need to handle multiple conditions using a single line of code
  • All of the above
A situation where you would use the ifelse() function in R is when you need to perform efficient vectorized operations. The ifelse() function allows you to apply a conditional operation to an entire vector or data frame, eliminating the need for explicit loops or individual element-wise checks. This results in more efficient and concise code.

How would you define a custom function to calculate the mode of a numeric vector in R?

  • Determine the most frequent value using table() function
  • Find the maximum count using max() function
  • Handle multiple modes using ifelse() function
  • All of the above
To define a custom function to calculate the mode of a numeric vector in R, you can use various approaches. One common approach is to use the table() function to count the frequencies of values, find the maximum count using the max() function, and handle cases of multiple modes using the ifelse() function.

In R, the value 'NaN' stands for ________.

  • Non-numeric Answer
  • Not Applicable
  • Not Available Now
  • Not a Number
In R, the value 'NaN' stands for Not a Number. It is a special value used to represent undefined or unrepresentable numbers like 0/0.

If a function parameter in R is given a default value, it becomes an ______ parameter.

  • Optional
  • Required
  • Conditional
  • None of the above
If a function parameter in R is given a default value, it becomes an optional parameter. This means that if the argument is not provided when calling the function, the default value will be used instead. It allows for flexibility in function usage and allows the caller to omit the argument if desired.

Imagine you need to create a 3D array in R containing the numbers 1 to 27. How would you do this?

  • array(1:27, dim = c(3, 3, 3))
  • array(1:27, dim = c(3, 9))
  • matrix(1:27, nrow = 3, ncol = 3)
  • list(1:27)
To create a 3D array in R containing the numbers 1 to 27, you can use the array() function and specify the dimensions using the dim argument. In this case, the dimensions would be c(3, 3, 3), indicating three rows, three columns, and three layers. The values 1 to 27 are passed as the values argument to fill the array.

In R, the mean of a numeric vector is calculated using the ______ function.

  • mean()
  • median()
  • sd()
  • var()
In R, the mean of a numeric vector is calculated using the mean() function. The mean() function returns the arithmetic mean (average) of the values in the vector.

In R, to include a backslash in a string, you would use the escape sequence ________.

  • /
  • //
In R, to include a backslash in a string, you use the escape sequence . For example, "This is a backslash: " would result in the string This is a backslash: .

"

What are the boolean values in R?

  • TRUE and FALSE
  • 0 and 1
  • "true" and "false"
  • T and F
The boolean values in R are represented as TRUE and FALSE. TRUE represents a logical true value, and FALSE represents a logical false value.

What is a nested loop in R?

  • A loop that contains multiple conditions
  • A loop that iterates over a sequence of values
  • A loop inside another loop
  • A loop that iterates backward
A nested loop in R is a loop that is placed inside another loop. This allows for iterating over multiple dimensions or levels of data structures, executing the inner loop for each iteration of the outer loop.