[R] readJPEG function cannot open jpeg files
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon Jan 14 18:56:00 CET 2013
On 14/01/2013 16:26, Suzen, Mehmet wrote:
> Similar issue with URLs:
Not a similar issue at all: a URL is not a file. That most functions in
R itself open connections including URLs does not mean that contributed
packages do. The package help is quite specific about its requirements.
source: Either name of the file to read from or a raw vector
representing the JPEG file content.
Which suggests to you how you can do this, apart from download.file, of
course. Something like
readJPEG(readBin(yesWeCan, "raw", 1e6))
>> yesWeCan <- "http://upload.wikimedia.org/wikipedia/commons/9/9d/Barack_Obama.jpg"
> can read
> can write
> Error in readJPEG(yesWeCan) :
> unable to open
> On 14 January 2013 14:57, Yi Yuan <lambandme at gmail.com> wrote:
>> I installed jpeg package and tried to use
>> kim<-readJPEG("kim.jpeg") to read in a jpeg file, but R gave me an error:
>> Error in readJPEG("kim.jpeg") : unable to open kim.jpeg
>> I already put "kim.jpeg" in Rstudio's default working directory: "E:\home
>> work\Rstudio". So I don't think it's a problem caused by omitting the file's
>> path. But I tried with the full path version just in case and still got the
>> "unable to open" error:
>> kim<-readJPEG("E:\\ home work\\Rstudio\\kim.jpeg")
>> Error in readJPEG("E:\\ home work\\Rstudio\\kim.jpeg") :
>> unable to open E:\ home work\Rstudio\kim.jpeg
>> So now I really don't know what is wrong.
>> [[alternative HTML version deleted]]
>> R-help at r-project.org mailing list
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help