Hi! I am Mike Marin and in this video
we'll talk about installing packages in
R
R is a computing environment where
statistical techniques may be
implemented
packages are add-ons that can extend
R's functionality and perform specific
tasks
covering a wide range of modern
statistics. packages
are contributed by individuals for
example
you may one day contribute a package
to R. they're often fairly specific in
what they can do
currently there are approximately 5,000
packages and counting
available for R. packages can be
installed
using the "install.packages" command
in R
or by using the menus within R. you can
access the Help menu
by typing "help" and in brackets
"install.packages"
when installing a package in R
the default values in the "install.packages" command
will usually suffice. if you know the
name of the package you'd like to
install
you can type that in quotations. in this
video
we will be installing the "epiR" package, a
package that we'll use later in the
series of videos
to do so again use the "install.packages" command
and here we would like to install
the "epiR" package; once we enter this
command,
you can see R asks us to select a mirror
this is a location where the package
will be downloaded from
I'm currently sitting here in Vancouver
so I'm gonna select mirror number 12: Canada(BC)
once we enter this
we can see R has now installed this package for us.
if you don't know the name of the
package you'd like to install
you can leave the package name blank in
this command
and R will return to you a menu of all
packages available
we can see here
R has returned to us a list of all the
packages
available within R. if you would like
to install
one of these packages we can simply
click on the package that we like to
install
click OK!
now normally
at this point R would ask for the mirror or
the location which you'd like to
download from. we've already entered this
once
so R will now know to use the mirror located
in British Columbia
a package only needs to be installed
once
once you've installed this package it's there
for life
unless you uninstall it. although the
commands
and functions built into this package
are only available to you
if you load the library of commands for
that package; for example
we can load the library of "epiR" commands
once we've done this we can now use
all the commands and functionality in
this "epiR" package
libraries disappear when ending an R
session
so you must load the library each R
session that you'd like to be able to
use the package
you'll also find a complete list of packages
on the "R-project.org" website
let's take a look at that
you can see here once on the
R project website we can click on this
CRAN link
to download R or packages for R
once here
we should select our location or mirror to
download from
I am going to select SFU as this is the
closest location to me
we can see now
we can get information on packages
available through this link
here we can select the packages
available
sorted by name or by day of publication
and here's a complete list of the
approximately 5,000 packages available
as mentioned they can be fairly
specific. for example
the ABN package: Data Modeling With
Additive Bayesian Networks
or this one here: Functions For Actuarial
Scientists
scrolling down the list we can see one
here
Power Analysis For Random Effects In
Mixed Models
now let's head back into R. to access
the Help menu
for a particular package we can type "help"
and specify we would like help for the
package
and in this case "epiR" is the
package would like help for
we can see over here we are returned a
list of all the functions and commands
built in to "epiR"
and we can access help for each of these
if you would like to delete or remove a
package
we can do this using the "remove.packages" command
here let's remove this "epiR"
package we just installed
all of this can also be done using the
menus in RStudio
I'm using a Mac here so it will be slightly
different for you
if you're using a Windows machine. in RStudio
we can look under the "Tools" menu and we
can see this
"Install Packages..." option; it's worth
noting
that here we can also "Check for Package
Updates..."
when we select "Install Packages" we are
brought to this menu
we would like to install it from "CRAN" that's from the R project website
here we can specify the package we would
like to install
we are gonna go ahead and reinstall "epiR"
this here's where to install it the
default is usually appropriate
and if we had no already specified
a location
or mirror here we would need to select which
location we're
in and would like to download from.now we can click install
and we're all good. "epiR" is installed
exploring the available packages and
which ones may be useful for you
can be quite specific to your area of
research
thanks for watching this video and make
sure to check out my other instructional videos
