This file contains 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(stringr) | |
names(iris) | |
#[1] "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" "Species" | |
names(iris) <- str_replace_all(names(iris), "[.]", "_") | |
names(iris) | |
#[1] "Sepal_Length" "Sepal_Width" "Petal_Length" "Petal_Width" "Species" | |
s <- c("Go to Heaven for the climate, Hell for the company.") | |
str_extract_all(s, "[H][a-z]+ ") |
This file contains 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(randomForest) | |
# download Titanic Survivors data | |
data <- read.table("http://math.ucdenver.edu/RTutorial/titanic.txt", h=T, sep="\t") | |
# make survived into a yes/no | |
data$Survived <- as.factor(ifelse(data$Survived==1, "yes", "no")) | |
# split into a training and test set | |
idx <- runif(nrow(data)) <= .75 | |
data.train <- data[idx,] |
This file contains 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
# load required libraries | |
library(shiny) | |
library(plyr) | |
library(ggplot2) | |
library(googleVis) | |
library(reshape2) | |
####creation of example data on local directory for uploading#### |
This file contains 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
## Add an alpha value to a colour | |
add.alpha <- function(col, alpha=1){ | |
if(missing(col)) | |
stop("Please provide a vector of colours.") | |
apply(sapply(col, col2rgb)/255, 2, | |
function(x) | |
rgb(x[1], x[2], x[3], alpha=alpha)) | |
} |
OlderNewer