Basj Basj - 11 days ago 7
R Question

Load an image in R, with no external package

Is it possible to load an image with R (.bmp or .jpg or .png or anything else), but without using an external package like this one :

> library(png)





Note: I don't want to require an external package, because it's for a course I'm teaching on university's computers where I think I cannot install package myself (and no time to ask sys-admin before the course...).

Thus, I'd like to load an image, but without having this error:


Error in library(png) : there is no package called ‘png’


because the package is not installed... This message was produced on my computer, showing that
png
seems to not be installed by default on Windows binaries
.

Answer

For future reference, here is a trick that allows to install packags on university computers that might have limited access:

setInternet2(T)

then:

install.packages('png')
library(png)
x = readPNG('d:\\photo.png')