Installing R packages

Select CRAN server

Click the R desktop icon to start R program.

The start screen should look like the following.

Click Packages on the main menu and then select Set CRAN mirror from the drop-down list.

There are dozens of servers around the world from where R and its packages could be downloaded and istalled. Select the one closest to you.

Click OK.

Select R package(s)

Click Packages on the main menu and then select Install package(s)… from the drop-down list.

List of all available packages will appear on the screen.

You can select more than one package from the list. Click the packages names while holding down Ctrl button. After selecting all the packages you want to install press OK.

Once installed packages could be used in R programs.

R codes

Experienced users will type commands for installation, loading, using and unloading packages directly into R console. We are using well-known professor Rob Hyndman package for forecasting time series forecast for illustration how to use these commands.

[code lang=”r”]
# Install forecast package
install.packages(‘forecast’)

# Load forecast package into R
library(‘forecast’)

# Use forecast package in R programs
forecast(object, …)

# Unload forecast package from R
detach(package:forecast)
[/code]