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!


http://www.inside-r.org/pretty-r/tool



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