Sunday, 8 April 2012

Pretty R

I just stumbled across a tool for syntax highlighting R code on web pages. It also sticks in hyperlinks to the help pages for keywords. This will make blog posting code easier!

totalrecords <- nrow(mydata)
trainfraction = 0.7
trainrecords = as.integer(totalrecords * trainfraction)
allrows <- 1:totalrecords
trainrows <- sample(totalrecords,trainrecords)
testrows  <- allrows[-trainrows]
#then build model, something like...
model <- lm(theFormula, data=mydata[trainrows,])
Created by Pretty R at