R Assignment (Part 2)
R Assignment (Part 2)
Stctstical arnatu8I6*
R has powertul and tlexible qraphicou
Ccpabilties Jn geberat terTs, R has twokinds
OF qrapty Coul CoFRETLALULdS; Sorme Co trtnands
enerute a basic pot Ot Some sort, cutnd
OtheY orrmioLlds He U6ed ' to tuweak the
output ond to produce a trOve cuftotru'zed
Fiaish
DifFerert Types OF PLotting in R
1)Box-ohusker pLots
Scauttey plots
3) ine Chatts
) Pie chats
5) Ctevelarnd dot chatts
Ban ChhcusS
Box-LIhiskeyPtots:
is a Usetul wa6
Lhe box - wtuskey plot
to viSuaLlize complex data here yoo have Di
rtipie Saumples Jn geneYal y o0 ie
Count Speed
Taw 2
25 3
ToYridge
Ouse 15
Exe
yn 4
BTOOK 25 24
pitch 24 29
Fcul 47 34
seEn tthese data beFove You cun
Vou have
wmnand to visualize
USe ttie boxpuot ()
One oF the vauuubles
here
boxplDt (fwspeed)
uke Figure T-l Fus
[tus produces a sirple qraph
oFa box-
Sthows the tupicu lcuyout
gYouph ShowS the medicul,
wtusker plot [he stripe
arnd ouwer
the boX vepresets the upper
the wushey &how ttie maximwm
h nges Cund
and irimwm vàulwes
to plot| you
JF yoU tave seveTal iterns
tthe vetoy nane in t e
CCLET SIttpy give
boxpLot ) Counand
>boxplot lfw g court , funfspeed)
3
25
20
Scattey Plots
fhe
The tasi plot
tasic C) DmUnarid 16 an exurp exaurp
Fonction ttiaut ccui be pressed
a Qenevid
ttt o sevvicc a
FOTvaiety oF 05es Hanu
statisttcal voubities tncdode
PECiatied
vootine to produce
a specialiZEd
plottitid howeve you
g'aph f0r tirne
He beitg
tthe ptott) orrumqnd to PYo duce
toft use
Scauttey The scauttey plot is used
pots
X tthe vetutionstup betwee
espeti uy to Shou
too voi dbles You rmet veYsion OE ttus i t
&C pots and tthe rovtnal distributipm
Basic Srcuttey Pots
he Fouowinq d cuta Fyutr1e (oritafry tuo
OE nutneric vaws) Cund becauwse
olwtrug
contin tthe Same twrrubey OE
tthey
Forttl tthe basic
Obsevatiorns, hey coold
FOY a Scattey plot
Fo count Speed
TLD
ToYidge 25
O06e 15
Exe 2
4
y
BrOOK 25 24
pitch. 24
fcu 41 34
he bastC for Ot ttie puot () wrUTIA LA
Yeeyuiyes yoo to
Specity ttie uld data
enci beiNq a nuneic vector You dse it ihe
S0
PLDt (X y
J yo0 have qoor data (orntuned ii a
data FYCume as in the touou0inq exaurple,
you nust use ttie syruax t0 get at the
you
Vc CLblPs yoo thugtt also 0së ttie with()
OY attCICti c) omEnctids: FoY ttie eXatple
data heve tte iouowinq Cormununds au
pYodUce a Sitrui lat vesut
ptot (uofsperd tw4 coutrt)
with Co, pLOt (Speed tourit)
attach (fw)
PLDt Cspeedr tooru)
detcucbh Ctw)
Adding Axis Labels
Yoo can produce yoor own axis labely easiy using
the xlb and ylab instrUCtions
plDtCfw $speed, Ewfenort , Xlab 3peed m/s' qlab=
COUtlt 0t Mayty)
210
0o
1C is 20 30 35 Fufrfd
Line Chauus looked at the ptot C Comum
S fauy yoo have 5 c a t t e r plots
and to produce
as awa yytbleg, OY aa
bleg,or
ttiey asa sinqle pair VotE
be cricuu
riay
Lt iple pci rs DLot
-
t t e Y e
d l t a tthut is
OLsiors. whern yoo have
h a t IS
m e dependeht tticut is/ dutcc
period OF ime
Duect ed over a
Segmets
Eype 'c - une segments ornuy witt Sma
ype "c
gps where the poitts would be
> witti Crnut, pot (terngth ro3, bype: ' )
witth (rat (ovdev Cmf tenqtti),J: plot (sort C
fergtt) NO3/ typ : ) ) .
Jn the Hrst cage ttie datl ae rwt sovted,
Cund ttie vesuult is a bie oF tries ( tthe
Yesult s hot shown here but yoU CeutlUry
It FOYyOUYSeLE 1:Jtu the Seond CLse ctie data
aHe soYted i and tthe vesult is a tot better.
200
Time
99Pie chovtts:
JF YOU have douti that represets how
Somettung is divided up between vyous
éhe pie chattis a comuon
Ccutegories
9TOLphu c Choice to iwstate yoor data foY
dautahat stowS
exaLnple Hou mught have
Sales POY Vau 0US iteImu GOY a w hole qea
enables YOU EO Show how
Che pie chtt
t 0 tOt sateg.
each
C ite
itetm COrnbibuuted
Feb
-Jun
6R NoV
Out p ec
SKIevelnd Dot Ctiats clevVE
An alteYticttive to the pie chat is a
e
and dot plot Au dua. ttiat truqht o
could als0 be
pYeseruted as a pie chat
PYeSetted as a baui chat oy a dot po
usi Tia
You Cn Cvecute teve land dot plDts
ttne dot chwtt C) Corrumand JE yoor d E
vectoy or vatwes ttien
uke tri
0Le a Simple
piec tommand yoU simpy give ttne vecto
ncuTme
>datatI; dautca 8
CIJ 3 5 15 3 2 6 568
CJ Jn' Feb' Ma' Ap' Mcu' Jun Jul
AOg
Aug' Sep' Ot' 'Nov' "Dec'
with a Pie cthutt you tmwst CYecute a pie Fov
the yowS oY the cowmrs Sepauitely, witth
he dot plot yoo con do bott1 at once
Dec
Nov
Oct
Sep
AU
Jul
Jun
-
Apr -
Hav 9-
Feb --
Jan
2 3 6 6 89
5Ba chats5 owin
For Showitn
Che baH sujtauble
b a chant is
dauta tht Fall into discrete Categorieg.
nq witth objects / goU
octinq o l t : worki
1s a Form oF
histoqran t whith
jn ttiat exuTLple euuh bay
Chat of
OF
graph Showed t e twnbey
e duta vawe.
tems
In o Certciti anqe of
BCUH
c ha t t s aHe widey
cha USed becuwse tthey
Dvey inFormation in a veadily onderstood
tlexiblë and caun
Pashion
Fhion [hey cHe also
&tuo items in vaioUs groupi9
OfnleCateqory Bau chuts3
TFie simplegt plot can be made FYom a
(wmericC valwe Jn the
e .vector oE
un item
FouDuD inq exarpe you have sveh
18 6 75 3 26 85
6 q8
CoErutnournd ound speify vetor.
baplot Croun)
BA chout