data("digits")
dim(digits)
table(digits[, "label"])
# Keep the label separate from the pixels.
label <- digits[1L, "label"]
digit <- matrix(digits[1L, -1L], nrow = 28, ncol = 28)
image(digit[, 28:1], col = gray((255:0) / 255), asp = 1,
axes = FALSE, useRaster = TRUE, main = paste("Digit", label))
Run the code above in your browser using DataLab