This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Including the required R packages. | |
packages <- c('caret', 'RSNNS') | |
if (length(setdiff(packages, rownames(installed.packages()))) > 0) { | |
install.packages(setdiff(packages, rownames(installed.packages()))) | |
} | |
# | |
library(caret) | |
library(RSNNS) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(caret) | |
library(tm) | |
# Training data. | |
data <- c('Cats like to chase mice.', 'Dogs like to eat big bones.') | |
corpus <- VCorpus(VectorSource(data)) | |
# Create a document term matrix. | |
tdm <- DocumentTermMatrix(corpus, list(removePunctuation = TRUE, stopwords = TRUE, stemming = TRUE, removeNumbers = TRUE)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="js/stopwords.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Including the required R packages. | |
packages <- c('shiny') | |
if (length(setdiff(packages, rownames(installed.packages()))) > 0) { | |
install.packages(setdiff(packages, rownames(installed.packages()))) | |
} | |
library(shiny) | |
shinyServer(function(input, output) { | |
submit <- FALSE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Including the required R packages. | |
packages <- c('manipulate', 'UsingR') | |
if (length(setdiff(packages, rownames(installed.packages()))) > 0) { | |
install.packages(setdiff(packages, rownames(installed.packages()))) | |
} | |
library(manipulate) | |
library(UsingR) | |
myHist <- function(mu) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Q1 | |
# Consider the following code for the cars data set | |
# This function plots distance versus speed, each de-meaned and an associated line of slope s. | |
library(manipulate) | |
myPlot <- function(s) { | |
plot(cars$dist - mean(cars$dist), cars$speed - mean(cars$speed)) | |
abline(0, s) | |
} | |
# Which of the following code will make a manipulate plot that creates a slider for the slope? | |
# A |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Including the required R packages. | |
packages <- c('openxlsx') | |
if (length(setdiff(packages, rownames(installed.packages()))) > 0) { | |
install.packages(setdiff(packages, rownames(installed.packages()))) | |
} | |
library(openxlsx) | |
data <- data.frame() | |
x <- sapply(month.name, function(month) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Developing Data Products - Quiz 2" | |
output: html_document | |
--- | |
Q1 | |
=== | |
In the slidify YAML text. Changing the framework from io2012 to shower does what? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Analysis of JNK holdings. | |
data <- read.csv('jnk-holdings.csv', skip=3) | |
data <- data[!is.na(data$Coupon),] | |
# Clean names. | |
data$Name2 <- sub(' \\d.+', '', data$Name) | |
# Find energy holdings. | |
e <- grepl('ENERGY|WIND|OCEAN| OIL |DRILL |HALCON|OCEANICS| OFFSHORE |DRILLING|PETROLEUM| PETRO | COAL ', data$Name, ignore.case = TRUE) | |
energy <- data[which(e),] |