# PLOT THE IMAGE OF A DIGIT. The arguments are the vector of pixel values # for the image (0-255), and the threshold to apply in displaying the pixels # as a binary array (default 128). plot.digit = function (pixels, threshold=128) { x = rep(1:28,times=28) y = rep(28:1,each=28) t = pixels>=threshold plot(x,y,pch=c(1,19)[1+t],xlab="",ylab="") }