Is there any way to install R packages using emacs?

I use ESS, but every time I need to install a new package, I have to use R gui. Is there no way to do this without leaving emacs?

+6
source share
4 answers

Cc ce i

Downloading all packages will take several seconds.

+5
source

From help(Startup) :

  ## Example of Rprofile.site local({ # add MASS to the default packages, set a CRAN mirror old <- getOption("defaultPackages"); r <- getOption("repos") r["CRAN"] <- "http://my.local.cran" options(defaultPackages = c(old, "MASS"), repos = r) ## (for Unix terminal users) set the width from COLUMNS if set cols <- Sys.getenv("COLUMNS") if(nzchar(cols)) options(width = as.integer(cols)) }) 
+8
source

If you do not remember the shortcut for installing the package, you can go to the main menu Handy commands .

If you type in the lower R-buffer as the first character (i.e., on the process market), you launch the menu of convenient commands in the minibuffer, as in the following figure:

install-pack

Notice how you can interactively select menu items by entering the initial characters (for example, using Emacs isearch). Of course, you can just use the arrows.

Choose install.packages (type i followed by enter should be enough).

In the next menu, you will be presented with a list of CRAN mirrors:

CRAN Mirror List

Choose a convenient mirror. ESS will select available packages

Get Available Packages

Then you are presented with a list of installed packages.

installable packages

Choose the one you need and you're done.

Please note that the second time you install the package in the current session, you are not prompted to re-select the mirror.

If you are not familiar with the convenient ESS commands, you can find many other commands here very ... well. In particular, with regard to the subject, the library command can help here, because you can enjoy autocompletion, useful also when you need to download a package, but you do not remember its spelling.

You might want to use the standard R GUI dialogs from Emacs. In this case, at least on Windows, to display the dialogs correctly, use:

 library('tcltk') install.packages() 
0
source

Source: https://habr.com/ru/post/892356/


All Articles