I'm trying to read MNIST database from URL using following code:
f <- gzcon(url("http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz"))
readBin(f, integer(), n=4, endian="big") # read header: 2051 10000 28 28
data <- matrix(readBin(f, integer(), size=1, n=28*28*10000, endian="big"), 10000, 28*28, byrow=TRUE)
Obtained data matrix contains "shifted" images, because the first call to readbin() does not move a file pointer, so the second call to readBin() rereads the same header.
Related topics are How to read MNIST database in R? and Read gzipped csv directly from a url in R , but it does not help to solve a problem.
Thank You for help!