Soup up your R environment: how to install packages

Today we are going to make additions to our R environment in a common process called installing packages. The transition won’t be as long, drastic nor emotional as an episode of Extreme Makeover: Home Edition, but it does add on more capabilities to your R environment.

Wow...I would like to live in a house like this

Extreme Makeover: Home Edition in Houston as published by Houston’s Real Estate Landscape Swamplot

A package is a bunch of codes combined and distributed through the different R mirrors/servers. Packages usually serve a specific function such as analyzing certain types of data or assisting in multi-server computing. Today, we are going to install ggplot2 and gplots, both of which are commonly used in creating different figures.

I will briefly enumerate the installation steps here which fall roughly into two parts. If you would like screenshots of the process in addition to the instructions, click here.

Method 1 (less typing)

Part 1-Getting the Package onto Your Computer

  1. Open R via  your preferred method (icon on desktop, Start Menu, dock, etc.)
  2. Click “Packages” in the top menu then click “Install package(s)”. 
  3. Choose a mirror that is closest to your geographical location.
  4. Now you get to choose which packages you want to install. If you would like to install multiple packages, click on each one while holding the CTRL key or the cloverleaf-looking key. For now just highlight “ggplot2″.
  5. You will know when the package has been downloaded onto your computer when another greater-than symbol (“>”) appears.

Part 2-Loading the Package into R

  1. Type “library(ggplot2)” and then press the Enter/Return key.
  2. All done.

You will only need to do Part 1 once time on your computer. From now on, you only need to do Part 2 each time you close and restart R.

Method 2 (Quicker)

Use this method once you get more acquainted with the whole copy and paste business. It is much quicker than Method 1.

Part 1-Getting the Package onto Your Computer

  1. Type “install.packages(“gplots”)” and then press the Enter/Return key.
  2. If you have already loaded a package from a server in the R session, then R will automatically install the package. If not, R will automatically prompt you to choose a mirror. Again, choose one close to unless you want to watch a loading bar slowly inch its way to fulfillment.

Part 2-Loading the Package into R

  1. Type “library(gplots)” and then press the Enter/Return key.
  2. All done. R will spit out a lot more output because it needs to install other packages required for gplots.

Again, you will only need to do Part 1 one time on your computer. From now on, you only need to do Part 2 each time you close and restart R.

About these ads

One thought on “Soup up your R environment: how to install packages

  1. Pingback: from OTU table to HEATMAP! | Learning Omics

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s