At Last - A Scripting Language I Like
I've always had a struggle enjoying scripting languages. JavaScript, Ruby, ASP, PHP and so on have never charmed me. I like my compiler. Then at my advanced age I started using R and I suddenly got it. I highlight a few lines of code in the editor, press F5 and that bit runs. Fiddle a bit, mark, F5, Ctrl-S to save the new version. What makes the difference is R's focus on loading data into memory and then letting you manipulate it. It has a tight, unpredictable syntax which cares about nothing but getting the job done:
items <- items[ items$Count > 100, ]Yesterday I worked out a neater way of calculating medians by group, and then a quick way of checking that it was equivalent:
xx <- split( data$Figure, data$Grouping ) zz <- lapply(xx,mean) items$Mean2 <- unlist(zz) range( items$Mean - items$Mean2 )Lastly I like building a chart, instruction by instruction:
plot(items$Mean,ylim=ylim)
points( items$Median,pch=4)
xdiff <- 1
ydiff <- ylim[2] / 20
indexes <- seq(1:5)
for(i in indexes )
{
x <- xdiff * i
y <- ylim[2] - ydiff * i
segments( i, items[i,]$Mean, x, y )
segments( x, y, x + 1, y )
text( x + 1, y, items[i,]$Name, pos=4 )
}
Still much to learn, much to love.

