Mittwoch, 1. April 2009

How to specify the library to search when running R CMD

Question: In case of multiple libraries, there are cases where certain library is prefered when runnign R CMD check, for example the one with more current packages. Although many documentation refers to set 'R_LIBS' variable in the environment to get around the fact that R CMD does not read configuration data like ~/.Renviron (the reason for this see here, due to '-vanilla' option), however it does not really work since when trying to do so and use .libPaths() in a vanilla session, we see that the default library is always the first choice to search.

Answer: Try use R CMD check XXX -l path/to/library, where XXX is the package one wants to check. The '-l' option confines check to search for the given library.

P.S., it took me almost one day to find this bug. I learned that it is necessary to state package version dependency explicitly.