Skip to Main Content
Go to Penn Libraries homepage   Go to Guides homepage

R for Business Guide

Quick start

  • Packages expand what R can do
  • Install new packages with
    install.packages('package_name')
  • Load packages with
    library(package_name)

Install a package

Install a package once per R installation (usually once on each computer). This downloads the content so it's on your system, ready to access.

  install.packages('package_name')

In RStudio, you can use the Tools > Install Packages... menu.

Use package content

You can call a function or object from a package directly. This uses part of the package without changing your R environment.

  package_name::function_name(...)

If you'll use a function or object many times, you may want to load the package instead. This lets you call the package contents like you would any other function/object.

  library(package_name)
  function_name(...)

Leave the library line in your code file; you'll need to run it once, each time you start a fresh R session.

Business & Data Analysis Librarian

Profile Photo
Kevin Thomas
He/Him/His
Subjects: Statistics

Chat

Penn Libraries Home Franklin Home
(215) 898-7555