Basj
Basj

Reputation: 46463

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.

Upvotes: 0

Views: 1369

Answers (2)

Basj
Basj

Reputation: 46463

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

setInternet2(T)

then:

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

Upvotes: 0

Roman Luštrik
Roman Luštrik

Reputation: 70643

If you write an image to .RData file without using any dependencies, then yes. Otherwise no, you will have to meet all the dependencies.

Upvotes: 2

Related Questions