Skip to content
Prev 11931 / 398502 Next

My_first_R_package: almost there

> Well, thanks to you all
  > I've been able to install my first
  > little package. I've dumped
  > some of my Splus(PC) functions
  > to an ascii file (*.R), created
  > the directory structure and the
  > DESCRIPTION and INDEX files. Then
  > I checked and installed with:

  > R CMD INSTALL -l ~/.R/library Sutilpangea

This is not a good idea, because the .R directory is a *temporary*
directory that R uses (on unix), and basically is created newly every
time you do help.start(), so your package will get deleted if you
install it there.

A typical place for private packages would be $HOME/lib/R but of
course you're free to use any place you like (except .R :-)


  > because I found that I have an .R directory
  > in my home where a subdirectory .R/library
  > has links to where the packages really are
  > (/usr/lib/R/library). Therefore, I decided
  > to keep  my own packages in .R/library
  > while the CRAN packages really stay in
  > /usr/lib/R/library.

  > Now the only problem is that, by default, R
  > searches packages in /usr/lib/R/library
  > because of the value of R_HOME:

  >> system ("echo $R_HOME")
  > /usr/lib/R

  > It would be better if R would
  > search packages in my .R/library
  > directory, where R would find both my packages
  > and the links for the CRAN packages.
  > How can I change the deafault searching
  > path for the packages? (I know
  > I can always do library(xxx, lib.loc="/home/alobo/.R/library"),
  > but it would be nicer having this as default).

One possible way to solve this problem: R searches all libraries in
the environment variable R_LIBS, please read the documentation.

Hope this helps,