Skip to content
Prev 4964 / 12125 Next

[R-pkg-devel] finding "logo.jpg" [was: "try" malfunctions on Ubuntu Linux 16.04 LTS, R-release, GCC]

????? Thanks to I?aki Ucar for identifying a second error that 
explained why I still got an error after wrapping one in "try".


 ????? That still leaves a question of how to find a file like 
"logo.jpg" in a platform independant way.


 ??? ? The following had worked for several years and now broke on rhub 
"Ubuntu Linux 16.04 LTS, R-release, GCC" but not on several other 
computers I tried:


 ??? ??????? logo.jpg <- paste(R.home(), "doc", "html", "logo.jpg", sep 
= .Platform$file.sep)


 ????? On that Ubuntu platform, "readJPEG(logo.jpg)" stopped with "Error 
in readJPEG(logo.jpg) : unable to open /usr/lib/R/doc/html/logo.jpg".


 ????? I replaced the above "paste" with the following:


RdocDir <- dir(R.home(), pattern='^doc$', full.names = TRUE)
RhtmlDir <- dir(RdocDir, pattern='^html$', full.names=TRUE)
JPGs <- dir(RhtmlDir, pattern='\\\\.jpg$', full.names=TRUE)
if(length(JPGs)>1){
 ? logoJPG <- paste0(.Platform$file.sep, 'logo.jpg$')
 ? logo.jpg <- grep(logoJPG, JPGs, value=TRUE)
 ? if(length(logo.jpg)>1)logo.jpg <- logo.jpg[1]
 ? if(length(logo.jpg)<1)logo.jpg <- JPGs[1]
} else logo.jpg <- JPGs
if(length(logo.jpg)<1){
 ? cat('logo.jpg not found.\n')
 ? print(R.home())
 ? print(dir(RdocDir))
 ? print(dir(RhtmlDir))
 ? if(!fda::CRAN())stop('logo.jpg not found')
} else {
# length(logo.jpg)==1 so continue:
 ? if(require(jpeg)){
##
## 1.? Shrink as required
##
 ??? Rlogo <- readJPEG(logo.jpg)

...


 ??? ? This gave me no error message, which I believe means that either 
length(logo.jpg) == 1 or fda::CRAN() returns TRUE.? Sadly, I could not 
find the standard test file to see which of these is the case.


 ????? I should proceed to submit the current Ecfun package to CRAN. 
Then I might modify this test sequence to force an error, so I can see 
more what is happening.


 ????? Suggestions?
 ????? Thanks,
 ????? Spencer
On 2020-02-03 03:06, I?aki Ucar wrote: