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".

The ________ function in R calculates the standard deviation of a numeric vector.

  • sd()
  • standard_deviation()
  • stdev()
  • variance()
The sd() function in R is used to calculate the standard deviation of a numeric vector. For example, if x is a numeric vector, sd(x) would return the standard deviation of the elements in x.

The _________ package in R can be used for advanced data reshaping and aggregation.

  • dplyr
  • ggplot2
  • reshape2
  • tidyr
reshape2 is a powerful package in R that provides methods to reshape your data between long and wide formats, as well as facilitating the aggregation of your data.

Can you describe a scenario where you would need to use a for loop in R?

  • When performing iterative calculations
  • When reading data from a file
  • When creating plots and visualizations
  • When installing packages in R
You would need to use a for loop in R when performing iterative calculations. For example, if you want to calculate a Fibonacci series, perform simulations, or generate a sequence of numbers based on specific conditions, a for loop allows you to repeat the necessary computations.

Imagine you're working with a large dataset in R and you need to remove a common prefix from a set of strings. How would you do it?

  • Use the str_remove() function from stringr package
  • Use the gsub() function
  • Use the sub() function
  • All of the above
All the options mentioned are ways to remove a common prefix from a set of strings. str_remove() from stringr, gsub(), and sub() from base R could all be used to achieve this, given the correct pattern and replacement arguments.

In R, to access the first column of a data frame named df, you would use ______.

  • df$1
  • df[, 1]
  • df[1, ]
  • df[[1]]
To access the first column of a data frame named df, you would use df[, 1]. The comma indicates that you want all rows and the number 1 specifies the first column.

When we assign a new value to an existing variable in R, the previous value is ________.

  • Ignored
  • None of the above
  • Preserved
  • Replaced
In R, when we assign a new value to an existing variable, the previous value is replaced. There's no built-in way to preserve the previous value when reassigning a variable in R.