13 Dec How to Install Packages in R
In this post you will learn a couple of ways to quickly import packages in R. As one of the most powerful statistical languages, R has gained popularity recently for its rich selection of packages that can add more tools to the hands of the developers.
The first way of installing external packages involves less typing. From RStudio environment, we select Tools from the ribbon and then the option Install Packages. From the pop up window we type the packages that we want to download and be available for us in the developing process. Also, we can specify the path to the package directory where all the packages will be installed and retrieved from R. The next image shows these steps:
The second way available to install packages is with the following line of code:
With this script, we install the ggplot2 and dplyr packages and also we specify the package directories in which they will be installed and retrieved everytime we need them.
To import the packages we have installed, in our code, we just type the following script:
In this exapmple, ggplot2 is imported.