I am just getting started with Ubuntu and want to program in R. I successfully installed the latest version of R (currently 2.12.2) from the terminal. I then attempted to run the following command:
> install.packages("XML")
Installing package(s) into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages("XML") :
'lib = "/usr/local/lib/R/site-library"' is not writable
Would you like to create a personal library
'~/R/i686-pc-linux-gnu-library/2.12'
to install packages into? (y/n)
Should I create the personal directory or did I miss a step somewhere that allows me to write to the site library.
Thanks in advance.
The comment by
sarnoldis quite correct. In the Debian (and hence Ubuntu) package, the directory/usr/local/lib/R/site-library/is created by the file/var/lib/dpkg/info/r-base-core.postinstscript — and the relevant code is:so the directory is owned by
root:staffand of mode 2775, or ‘user and group read-write, others read-only’.So to write there, you have two basic choices:
Always use
sudoor becomerootwhich is clumsy.Add yourself to the group
staff. There is probably a user-friendly GUI for it; I am Unix old-school and do that by hand by editing/etc/groupand/etc/gshadow— after that you can install directly (well you need a fresh shell to have those rights, or just start a new terminal). You can of course also pick a different group, or create one, but then you need to also alter the directory tree in/usr/local/lib/R/accordingly.Hope this helps. The r-sig-debian list is a friendly place for Debian/Ubuntu questions like this and I recommend it. The question has come up there before.
Edit: Also, a fair number of (more complicated) packages are part of Ubuntu / Debian, so to get XML you can just to
sudo apt-get install r-cran-xml. Do anapt-cache search r-cranto see what is available.