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
test.line = "some characters" | |
print(test.line) | |
test.fun = function(x){ | |
print(x) | |
} |
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
Nsheets = function(FILE){ | |
FAILED = FALSE | |
i = 1 | |
while(!FAILED){ | |
test = try(read.xls(FILE, sheet=i), silent=TRUE) | |
if(class(test) == "try-error"){ | |
stop(return(i-1)) | |
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
#Using 64bit R 2.15.3 | |
#Packages we are going to use | |
library(rjson) | |
library(data.table) | |
library(rbenchmark) | |
#set your WD where your unpackaged file is, or add path. | |
#Reading only partial data for this test, you can naturally do as you wish | |
eve = readLines("kms-2013-01-06-s.json", n=3001) |
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
#Multicore (mc) requires snow package as multicore isn't on windows... | |
require(snow) | |
mc.fast.merging = function(data.list, nparts, cluster){ | |
if(!is.list(data.list)) stop("data.list isn't a list") | |
while(length(data.list) != 1){ #Loop until everything is merged |
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
#Using 64bit R 2.15.3 | |
#Packages we are going to use | |
#download the packed data here: https://www.dropbox.com/s/c1rtcryp8p6500w/kms-2013-01-06-s.json.bz2 | |
library(rjson) | |
library(data.table) | |
library(snow) | |
library(rbenchmark) | |
#set your WD where your unpackaged file is, or add path. | |
#Reading only partial data for this test, you can naturally do as you wish |
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
require(gdata) | |
require("RCurl") | |
require("XML") | |
AtcSearch <- function(AtcCodes){ | |
#Function inside a function is bad practice... | |
#DummySearch searches for one atc code | |
DummySearch <- function(Code){ | |
#A link to WHO search |
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
#Example for the kaggle forums. | |
library(FNN) | |
library(stats) | |
train <- read.csv("data/train.csv", header=TRUE, comment.char="") | |
test <- read.csv("data/test.csv", header=TRUE, comment.char="") | |
N <- 30000 | |
set.seed(20140202) | |
trainingSet <- train[sample(1:nrow(train), N), ] |