Data Frames In R: Test Your Knowledge! Trivia Questions Quiz

20 Questions | Total Attempts: 22

SettingsSettingsSettings
Please wait...
Data Frames In R: Test Your Knowledge! Trivia Questions Quiz

Below is Trivia Questions Quiz to test Your Knowledge on Data Frames in R? If you are looking for a way to refresh your understanding of the data frame in preparation for a quiz or exam, the questionnaire below is precisely what you need to garner the high score. How about you give it a shot and get to see how well you will do.


Questions and Answers
  • 1. 
    Which of the following R functions can be used to return a vector?
    • A. 

      ar()

    • B. 

      array()

    • C. 

      c()

    • D. 

      character()

    • E. 

      list()

    • F. 

      numeric()

  • 2. 
    When subsetting a single column from a data frame, what parameter can be used to return it as a new data frame as opposed to a vector?
    • A. 

      as.vector

    • B. 

      drop

    • C. 

      simplify

    • D. 

      unlist

    • E. 

      None of the above.

  • 3. 
    What function is used to apply another function overall rows or columns of a data frame or a matrix?
    • A. 

      apply()

    • B. 

      lapply()

    • C. 

      mapply()

    • D. 

      tapply()

  • 4. 
    What function is used to load an R package?
    • A. 

      import()

    • B. 

      load()

    • C. 

      package()

    • D. 

      source()

    • E. 

      None of the above.

  • 5. 
    Which of the following are the elementary R types?
    • A. 

      character

    • B. 

      decimal

    • C. 

      double

    • D. 

      integer

    • E. 

      logical

    • F. 

      numeric

    • G. 

      ordinal

    • H. 

      string

  • 6. 
    Which of the following is the operator for element-wise OR?
    • A. 

      %in%

    • B. 

      &

    • C. 

      ifelse()

    • D. 

      or

    • E. 

      None of the above.

  • 7. 
    What function is used to apply another function over grouped subsets of a vector? Pseudocode example: if the data vector has values [1, 2, 3, 4, 5, 6], the grouping vector has values [0, 0, 1, 1, 2, 2] and the function to be applied is func(), the results would be [func([1, 2]), func([3, 4]), func([5, 6])].
    • A. 

      apply()

    • B. 

      lapply()

    • C. 

      sapply()

    • D. 

      tapply()

    • E. 

      None of the above.

  • 8. 
    Which of the following functions returns the cumulative density of the Poisson distribution?
    • A. 

      dpois()

    • B. 

      ppois()

    • C. 

      qpois()

    • D. 

      rpois()

  • 9. 
    Which of the following functions can be used to stack data frames columnwise?
    • A. 

      cbind()

    • B. 

      combine()

    • C. 

      data.frame()

    • D. 

      stack()

  • 10. 
    Which of the following options orders data frame df by its column named 'col'?
    • A. 

      df[order(df$col), ]

    • B. 

      df[rank(df$col), ]

    • C. 

      order(df, 'col')

    • D. 

      sort(df, 'col')

    • E. 

      sort(df, df$col)

  • 11. 
    Which of the following commands selects columns named 'a' and 'b' from data frame df?
    • A. 

      d[['a', 'b']]

    • B. 

      df[, ['a', 'b']]

    • C. 

      df[, c('a', 'b')]

    • D. 

      df[, list('a', 'b')]

  • 12. 
    Which of the following commands can be used to extract all values <2 from vector vec?
    • A. 

      choose(vec, vec < 2)

    • B. 

      if (vec < 2) { vec } else { NULL }

    • C. 

      vec[vec < 2]

    • D. 

      vec[if (vec < 2) TRUE else FALSE]

    • E. 

      vec[ifelse(vec < 2, TRUE, FALSE)]

    • F. 

      vec[which(vec < 2)]

  • 13. 
    By default, functions read.table() or read.csv() convert strings representing dates to which of the following data types?
    • A. 

      character

    • B. 

      factor

    • C. 

      integer

    • D. 

      string

  • 14. 
    Which of the following commands return a concatenated vector from vectors a and b?
    • A. 

      (a, b)

    • B. 

      a + b

    • C. 

      append(a, b)

    • D. 

      c(a, b)

    • E. 

      list(a, b)

    • F. 

      paste(a, b)

  • 15. 
    Which function can be used to create a vector with consecutively repeating elements? Example output: (1, 1, 1, 2, 2, 2, 3, 3, 3)
    • A. 

      rep()

    • B. 

      seq()

    • C. 

      seq_along()

    • D. 

      sequence()

  • 16. 
    R plotting functions: select all of the following that are true.
    • A. 

      A histogram is plotted by parameter setting type = 'h' in function plot().

    • B. 

      Function points() is used to add points to an existing plot.

    • C. 

      In function plot(), logarithmic axes are set by parameter setting log = TRUE.

    • D. 

      Plot limits are controlled using parameters x_range and y_range.

    • E. 

      Colours can be set with both RGB value strings and colour names.

    • F. 

      The bounding box of a plot is suppressed by parameter setting bty = FALSE.

    • G. 

      The size of the plot characters are controlled using parameter cex.

    • H. 

      X and Y axis labels are set using parameters xlab and ylab, respectively.

  • 17. 
    R plotting settings: select all that are true.
    • A. 

      A figure is split into multiple plots using par(mfrow) or par(mfcol).

    • B. 

      Return values in par('usr') are limited to numbers between 0 and 1 (inclusive).

    • C. 

      When plot() is called with parameter setting xaxs = 'i', the X-axis limit of the plot is set exactly as wide as the data range.

    • D. 

      Parameter las is used to set axis labels as horizontal or vertical.

    • E. 

      Setting par(new = FALSE) is used to add a new plot over the old one without removing the old one first.

    • F. 

      Values outside plot limits can be revealed by parameter setting xpd = TRUE.

  • 18. 
    Advanced R plots:
    • A. 

      Function lines() is used to create connected line graphs and and disconnected line segments.

    • B. 

      Parameter angle in function barplot() controls the line pattern of the plotted bars.

    • C. 

      Parameter at in function boxplot() controls the width of the individual box-and-whisker units.

    • D. 

      Parameter beside = TRUE in function barplot() is used to create a grouped barplot.

    • E. 

      A Kernel density line can be added to a plot created by function hist() by using parameter density.

    • F. 

      Parameter range in boxplot() controls the outlier threshold.

  • 19. 
    R statistics:
    • A. 

      Function anova() can be used to perform likelihood ratio tests.

    • B. 

      Function chisq.test() can be used to perform Fisher's exact test.

    • C. 

      Function glm() can be used to fit a logistic regression model.

    • D. 

      Package glmnet is used for generalised network analysis.

    • E. 

      The distance metric used in function hclust() is set using parameter method.

    • F. 

      The intercept term in linear models can be removed by adding a zero term 0 as follows. response ~ 0 + ...

  • 20. 
    Which of the following R functions are used for debugging R code?
    • A. 

      browser()

    • B. 

      debug()

    • C. 

      source()

    • D. 

      step()

    • E. 

      trace()

    • F. 

      traceback()