开发者

installing R packages on ubuntu 8.10

preface: i'm an os x user coming to linux, so excuse my ignorance in advance

I've installed R using synaptic and now i'm trying to install packages.

I open R then try

install.packages开发者_JAVA技巧("some_package")

system tries to default to /site-library, then tells me it's not writable, then asks about making a personal library?

Should I just make site-library writable? Or is there something more to this?


The directory /usr/share/local/lib/R is the default location; the directory is has ownership root:staff by default. If you add yourself to group staff (easiest: by editing /etc/group and /etc/gshadow) you can write there and you do not need sudo powers for the installation of packages. That is what I do.

Alternatively, do apt-get install littler and copy the example file /usr/share/doc/littler/examples/install.r to /usr/local/bin and chmod 755 it. The you can just do sudo install.r lattice ggplot2 to take two popular examples.

BTW Ubuntu 8.1 does not exist as a version. Maybe you meant 8.10? Consider upgrading to 9.10 ...

Edit: Also have a look at this recent SO question.


I faced the same issue. The most convenient way is to start R as super user.

sudo R

After that, install.packages("some package") should work.


If you are the only user who needs those packages, then the easiest and neatest way is to let R create a personal library for you. That way you don't need to mess with the system directories managed by the package management system.

Another way to install some packages in Ubuntu is to look for Ubuntu packages with names like r-cran-*. This way you do not have to worry about dependencies, the packages become available to all users, and updates are taken care of by the Ubuntu package management system. But only a small proportion of CRAN packages are available this way and you may not get the latest version.


Well, I prefer to install packages into local R folder ~/R/, but it's just a matter of an individual preference... you can also grant yourself a write permission to default library, it doesn't make any difference.

Be sure to add up-to-date packages. Those packages available in default repos are quite old. R v.2.9.0 is available by default in 9.10, while v.2.10.1 is now available. So stay up-to-date, add this line to file /etc/apt/sources.list (replace <text> with CRAN server address, you can find server addresses on www.r-project.org > CRAN > Linux > Ubuntu):

deb http://<my.favorite.cran.mirror>/bin/linux/ubuntu karmic/

then run this line in terminal:

gpg --keyserver subkeys.pgp.net --recv-key E2A11821 && gpg -a --export E2A11821 | sudo apt-key add -

and if keys are imported properly, run:

sudo apt-get install r-base-core

or if you already installed R, run:

sudo apt-get update && sudo apt-get upgrade

you should also check for alias functions (try man alias in terminal) to automatize repetitive tasks... feel comfortable in terminal, Synaptic is indeed a good tool, but most Linux users prefer command-line approach for a good reason - it's highly customizable =)

I recommend that you stick with one server (be advised when choosing the default server - I prefer UCLA's server, Berkeley works just fine, Main server is usually busy as hell... so there...)

Alternatively, you can add default CRAN server to .First() function:

# replace '<server address>'

.First() <- function() {
options("repos" = c(CRAN = "<my.favorite.cran.mirror>"))
}

now you can just type:

> install.packages('<somepackage>')

and you'll lose the boring Tcl/Tk serverlist window! Oh, what a relief!

Welcome to Ubuntu!
Cheers, mate!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜