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(XML) | |
library(ggplot2) | |
url <- "http://www.kaggle.com/c/acquire-valued-shoppers-challenge/leaderboard" | |
tree <- htmlTreeParse(url) | |
tbl <- readHTMLTable(pagetree, stringsAsFactors = FALSE)[[1]] | |
colnames(tbl) <- gsub("[^a-zA-Z0-9#]","", colnames(tbl)) | |
tbl$Score <- as.numeric(tbl$Score) |
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
# calculation as per: | |
# http://www.bmj.com/content/343/bmj.d2304 | |
get_odds_p <- function(est, cil, ciu) { | |
se <- (log(ciu) - log(cil))/(2*1.96) | |
z <- abs(log(est)/se) | |
p <- exp(-0.717*z - 0.416*z^2) | |
p | |
} |
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
rm(list=ls()) | |
rcode <- "x <- 1+1; y <- 2+2" | |
# running `eval` evaluates `rcode` into the parent environment | |
eval(parse(text = rcode)) | |
print(x) | |
print(y) |
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
# Use autodetected proxy settings | |
setInternet2(TRUE) | |
# Get the SpotfireSPK package from the Spotfire Stats Server | |
install.packages("SpotfireSPK", repos = "http://MySpotfireServer:8080/SplusServer/update/TERR") | |
# Get a package you want to deploy from CRAN | |
install.packages("nortest", repos = "http://cran.us.r-project.org") | |
# Create a Debian Control File |
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
# Download: http://tap.tibco.com/ -> "Samples" tab -> RinR -> "Try Now" button | |
# Docs: http://docs.tibco.com/pub/enterprise-runtime-for-R/2.5.0/doc/html/RinR/RinR-package.html | |
######################################## | |
# Setup | |
######################################## | |
library(RinR) | |
library(Sdatasets) |
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(httr) | |
library(devtools) | |
# make httr set CURL to ignore SSL verification problems | |
# (needed if the SSL proxy replaces certs with its own) | |
set_config(config(ssl.verifypeer = 0L)) | |
# set proxy details | |
set_config(use_proxy("10.10.10.10",8080)) |
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
TBD |
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
####################################################### | |
# | |
# Expression Functions in Spotfire can take arbitrarily | |
# many columns as input. Columns will be passed to TERR | |
# in order as 'input1', 'input2', etc. | |
# | |
# This shows how to capture an arbitrary number of | |
# columns and to put them into a data frame. | |
# | |
####################################################### |
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
################################################################### | |
# Takes an arbitrarily long list of input columns and returns a | |
# boolean indicating whether or not each row is an outlier. | |
################################################################### | |
# create vector of inputs | |
inputs <- grep("^input[0-9]+$",ls(), value = TRUE) | |
# capture columns as a matrix | |
x <- sapply(inputs, function(y) {eval(parse(text = y))}) |
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
######################################################## | |
# Takes an arbitrarily long list of input columns and | |
# returns a boolean indicating whether or not each row | |
# is an outlier. | |
# | |
# The function uses the critical value for Mahalanobis | |
# Distance calculated from an upper tailed ChiSq | |
# distribution with p=0.001. | |
######################################################## |
OlderNewer