Skip to content

Instantly share code, notes, and snippets.

@primaryobjects
Created February 5, 2016 19:25
Show Gist options
  • Save primaryobjects/81bfff7655c03652b96f to your computer and use it in GitHub Desktop.
Save primaryobjects/81bfff7655c03652b96f to your computer and use it in GitHub Desktop.
Coursera Developing Data Products - Quiz 3
# Coursera - Developing Data Products - Quiz 3
# Q1
# Which of the following items is required for an R package to pass R CMD check without any warnings or errors?
# A
# DESCRIPTION file
# Q2
# Which of the following is a generic function in a fresh installation of R, with only the default packages loaded?
install.packages('pryr')
library(pryr)
ftype(lm)
# "function"
ftype(dgamma)
# "function"
ftype(mean)
# "s3" "generic"
ftype(predict)
# "s3" "generic"
ftype(show)
# "s4" "generic"
ftype(colSums)
# "internal"
# A
# mean, predict
# Q3
# What function is used to obtain the function body for an S4 method function?
showMethods(show)
getMethod(show)
# A
# getMethod()
# Q4
# Please download the R package DDPQuiz3 from the course web site. Examine the createmean function implemented in the R/ sub-directory. What is the appropriate text to place above the createmean function for Roxygen2 to create a complete help file?
# A
#' This function calculates the mean
#'
#' @param x is a numeric vector
#' @return the mean of x
#' @export
#' @examples
#' x <- 1:10
#' createmean(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment