1. Introduc)on
to
R
and
RStudio
Corey
S.
Sparks
Department
of
Demography
The
University
of
Texas
at
San
Antonio
September
22,
2012
Sponsored
by
the
UTSA
Department
of
Demography
2. What
is
R?
• R
is
a
system
for
sta)s)cal
computa)on
and
graphics.
• It
is
heavily
influenced
by
the
S
language
• R
was
ini)ally
wriJen
by
Ross
Ihaka
and
Robert
Gentleman
at
the
Department
of
Sta)s)cs
of
the
University
of
Auckland
in
Auckland,
New
Zealand.
• The
“R
Core
Team”
maintain
the
source
code
for
the
soPware
and
release
regular
updates
3. What
is
R?
• The
R
soPware
contains
func)onality
for
a
large
number
of
sta)s)cal
procedures.
• Linear
and
generalized
linear
models
• Nonlinear
regression
models
• Time
series
analysis
• Classical
parametric
and
nonparametric
tests,
clustering
and
smoothing.
4. What
is
R?
• In
addi)on,
the
R
project
is
added
to
by
many
of
its
users,
who
write
source
code
for
many
different
types
of
analy)cal
procedures
• Everything
from
analy)cal
chemistry
to
epidemiology
to
linguis)cs
– OPen
code
is
wriJen
in
FORTRAN
or
C++
and
ported
to
R
– Currently
4,045
different
user-‐wriJen
libraries
available
5. Where
can
I
run
R?
• R
runs
on
a
variety
of
plaorms
– Windows
– Mac
OS
X
– Linux
– Unix
• 32
and
64
bit
installa)ons
• Support
for
parallel
compu)ng
and
clusters
6. Revolu)on
R
• Commercial
version
of
R
soPware
• Revolu)on
R
is
compiled
for
mul)-‐core
support
• Allows
for
a
marked
reduc)on
in
computa)on
)mes
because
of
op)mized
code
and
certain
math
system
libraries
(BLAS,
ATLAS,
etc)
7. What
makes
R
so
great?
• Open
source
• User
community
• Cudng
edge
development
• Integra)on
with
low
level
programming
languages
• Flexibility
• Mul)-‐language
support
8. The
R
Interface
• Depends
on
where
you
run
it
• Different
OS’s
have
very
different
interfaces
• R
is
inherently
command
line-‐oriented
• Several
GUIs
have
been
wriJen
9. RStudio
• Rela)vely
recent
incarna)on
of
an
R
IDE
• Open
source
• Desktop
and
server
versions
• Lots
of
cool
features
– syntax
highligh)ng
– workspace
and
data
browser/editor
– integrated
help
system
– integrated
history
– runs
on
all
OS’s
19. Addi)onal
Cool
things
• Mul)ple
project
management
– Keep
mul)ple
code
files
for
separate
projects
• Lots
of
keyboard
shortcuts
• Generate
HTML
reports
with
knitr
• Customized
IDE