You are on page 1of 9

R Prog7amming.

hat5 CVan2
COmpreh ensive RArthive network is a coll etion
osites which
sites earr ideticad matenals Consistthg o 4he
he coriribted extensions, dotumentatwtn
R crsd ributon
binartes.
and
tor R

whl is R ?
that i
Proqsamminq anguage
K is en Opensource
an a tattchcod Souware and a t a anaky cg
wi dely uned

tod .
weih the command-line inerfsLe
R3eneraly comeg

ike winclols, Linur and


Linux an MacOS
VartatuD platfovms

Wha ts Rhucro?
nvirom ent for R,
is an inteqrated developmerl
R studio Compuhing raphits
Proq ramming Carqua e fortatishcal
Larguag

R-ctudio
R- deckt0P Seve
Studio
On a remole sedves&
uns
TunS Requlav deskoP
allocys accescing R-stuclo stmg
applicatwn qweb browsev
nser
Locat Cnvirmental setup.
windoD well o
Both inctallaton for

R- Datayp
need to De vviotD VnGhles
9 R- praqramming,
to stort van'ow noatron
oeation to tove
>Vanables re recervecd memdry aluea
we cveale aVana'bie we Serve S0 me
Means when
in emory
Spate

data pe CharaHer, 9nteger floatnq point


poit, Boolean
double bloak n

Th ere are d4fevent objeets n R, and vatos 0bed


s one ob hem
Vettor objeet tntlucles.

Numernc
dat

pes
Omege
Complex
charade

How to fmport data i n R 2

sin
Using read. csv () funetrgGn
walue
CS V Lomma separatec
This csv functton a Parameters.
fle. chocsel) 9 t opens a m enu to choose a

fele drom the desktop,

the rst row o Ihe


OHeader 94 is to indrale
data set 1 Vanqb les or not

SF Utables name is hee.


APph T/True
data se is amec data1,
e
9f

4data
4hen
1-read» csv f:le.chcose( ),heacd es : TL

Operatorsh R

are 1he sumbols directnq t h e compile


These
Kincds Os operattpns etween operancs
perfem
Operaton
3/P/0perands Outp
Math emat aal
gcat 8
9teqevs
numertals, ectsion
aperatons.
Co m p l e x nmbers

Varioun p e s ofoperators,

Arithmete opevetovs T, - X*
O NOT)
operstor(T, F,DR, AD
gread 7> l=
Relqteon opeto (>,2,
Assiqnmerl operatov.
data
values to vanbuy
CAssiqning
obeets irn R)

Keywords n
repeat, for.
9, else, öhile,

aviables in R toraqe of
alotatefor th e
Variable f6 memory
weth the Vauabje
-

nd h e Kame te
data
spautic Van'ables
= Varicbic namnt

Name 9 iven to he
ne
to a Cevta
Certain
dat belonging
Sinqle VGvGble s
stto
orre
e ss
he

da tp
vanables
Three way f aneihng from
from igh
igks
to left.
to left
data
data is Copied
Copied
Usin operataLL
varigble n a m e -Vglue.
InsE"

Osinleli coard aperaBor.


from z to left
ata s copiecl
value
KO
name
Varia ble -

Osinq nghtware opeyatov


frem left to orqh
o piec
vqlue
vanqble -name

cope o variqbles in R

Dynamic stoping

R s an Open surce Proramminq anguag e lhdis


widely une aM a ctatestcal 8Atoae 8 data An
wicdel
to.

Comes wedh tommand line interface.


lalest uteng-e dqe tool.
fooOL.

f tunction (*,9)
a +9/z

t y are two 4quments.forma


rules
an olhez dymbol z, Here opinq
is a
There
how Ualues a e nsiqne t the free
defines
Language
vahiables

>Free vQvablees Lre not formal arquments nos the


Loca v&vrables.
ans he Vaviqble t (free)
lexian stopinq in R
s
are Searche fn he environmen in which functt on
defined. Seavchinq for the ualue foy
fer free v&nable
is not Contineq
9 F
the
the
value found, then search
in 1he
parent environment

o he paven
search
search
cortlnues down 1he stquence
environmenz
The
virommert until
unil 1he
1b uners hit the top-level
en
or enviror enl o f a
is
he workspate global
This

e n v i r o n m e

package

One
1he empty
vglue fs not 6ond
P the
9 an evror s hrouwn
ec, 7hen
qvrive
han

structure inK Proqrammin


Data
R Strinqs
vanablec
are banially a bunch 0b chara eter
strings
g s Q one dimensronal
array ob chavacters. vglues ih R.
duble quotee
are always tored
sArings
which
R-veetors C-Lanquage,
tn
Qre same an arraj he
same
VectorS
Otore multtple
data valueg o
wned to
is

starts from 1
fhe R be cvected
9ndexinq chorctev
vectors can

well a
an
Numeric

hedevoqeneous clate e
elle
emme
ênntttt .
cdata
R-Lsts welh beee voqen eous
avector
is a
li's
hu ilh data
data
heierogeneoun
hejeroqeneoun
one- dimen.sion 2 funethionj
tis merices, echarast ers
9 9
7 can
can be a lisd o veetors,

- vker Arra
number ob demen sions .

Wih fxecd
Data utoraqe memor
memory
ob pare Coiquou
Cohquous
Qlloeateon
Used for
Used
Locatomns
vertorS
Uni-dimens joe arra mal réces.

Two
Factors
he data Or epreseKt
Us

value/data
ed to caleqorise
and store t nmltple levels canegorrea
Data rames

D a t a frames are generic deta uneolto tore the


tabular data
-9t can be tn forms ofmatrdces , Where each col
each olumn
CAn be o dtferent data type

Data frame = data + TOOS t columns

Error handling
9t fs process tn hrch we have to dea with
he unwated errors hich may Cune abnormal
termination ob the proqram durinq ts execution

Stop) functon warntnq ) tuncton here


we Can fmplemenl an error haddhnq meehanrsm .

Frle handliog
Handlinq files means Teading & wrting file
files

Ele, 7*maminq 1he kle check. the


Caeatinq ,

existencee he l e listing ql the ls


Hhe wov Kinq diredtor.

Packager in K
OLattice packa e
99plot 2

elo41
1puokpkap pivottabler
atHice ackaqe

l a H i t e
s a
s Powef data vrsualicstton
packaqe For
ogramn ith an
R emphanis 0n mu Hivartate data

sa 3rphe PacKaqe in piree by


9raph Arellis qraphrrs
9rphre
package

ha wrde varlety funcions h enable to


94
- Cu de banlc plots of 1he R paukaqe

5caHer plot

a
The xyplot) functton Can be uned t o CreHe

ScaHer plot oing latice paekaqe


6aned on
we can even colour the data Potts
eadegores.
dhe x, y labels
- e ean change he plot nin
oolhing
i'nu to
7h
-we can also add tm

this tunchion.

Box plot abox plot


uned to crece
bwplot functton violtn plot.
even creqte
can
this tuncton w e on ahe
the
Vsinq plot bgo
plots ed
boeo
also creoote mutipl
mutiple
can
We

group
in R.
clot plot:
Creote
Dat plots enables
to
dotplot () funeton

(dot plot )

trp plob stripplotC) functon 0

L
ei
Density plot

Densityplot ()

istcqram
tistaqraml)

99plota
>arammar 0 grphie
statstcas
chart -makinq ydem for
he
A A

Proqramming languaqt
visualrsation
dedirate to data .

-9t s a paekaqe
improve he quality 2 stheticc of
taan greal
9raphiee
qmost qll charts.
t make

9. ustomising
caustomisinga tile, aclclinq annotation or

uninq faeting.
Hnnotaon
')For clata visuarsation.
chart
Alloos t htqhligha he main messaqe of the
u) meclium
turns a
messq tequre in an insrqkifud
1) 3
The hemet funetion
allows to
4pearance Cutomse he that
94 comrols 1hree
u) main Componersts .
) Axs (ile, la
b) Backoqound
bet)
col ours,grd Itn**)
egends (potitron ,text, ymbol)
Reorderin9
hen workinq wth cleqorea valuts/factors, a
tomm0 r u g l e s to ent4ieon
manaae he orcdev of
he plot
4 s dedrcateq to
1e-ovdering

to h e
chart.99tet
TiHle Allows to acld a ttle

ho to title mün feahures. moTe.


å many
POitton font, colaur, text

dh 99plot can
qlso
also be d done
(ugtom fonts

e 10 1 Packouqe proqramming
h
t ha
a

paeaqe for
forR-
eloFI s a 3 probailstic
alqonthms
alqonthms
for stattstte
fun ctions maehine ete.
provrdes veutor
cusenng
Spport
UKe baggec

Pivottablez
package
be creod ed & expo rt ed.
tables to
Enables pivo a39rqst
framewort for speeifymq
a imple
Provicling
7 froviclinq
d a t a . t a b le pa Eage
data bantd on
ustom
Custom cocl
cclcucul ateons
atons
Provtdes optonal
hooks for pecfing
aggregeton for complexcenartos.

in multiple fomats
tormats.

0r
Supports
Supports op either standard Rmatrix

pivot tble
to
-Converts a data frame.

You might also like