0% found this document useful (0 votes)
10 views10 pages

R Assignment (Part 2)

R Language For Data Science

Uploaded by

18.Suresh Bhukya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views10 pages

R Assignment (Part 2)

R Language For Data Science

Uploaded by

18.Suresh Bhukya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

30) P[ottitg in ktdit[everut eJPCs)?

Gaphs UHe a powerluu w to presen


A)
yoUY dCuta and vests Itia Oncise tncuuney,
whatever kind of data 00 iave ttieve isa
w to iwstrate it graphicay A qraph is
t i a l words
moYe Yecadiuy vrnderstcundable
and twrrbers, and produu good gyaphs
is a vitcu Skiu Sorne graphs avle aso
Useut n exururnq data 60. that yo car
qain 6ome idea Of patterng that mcuy exist;
Htuis Can direct y00 towaHd the wmect

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

ookinq t0 displcuy direevences Betwe en


COORinq
Sdmptes CFie bayic roYm OF the box 0SE
One
COisker plOt stuows the mediun valwe, ttie
avartites ,cnd the mcxl riici vauves lFus
tmeans tthcut you qet a tot OF'inFortation [h
n a cormpact maneY
The boX wruisker plob 1s atso eseful to0 w
vi Sbaize a Sample beccuwse yov can the
singte
ShLoo ouLttievs ie youchoase Yov CCun use the hut
aan
boxplotC) CoTmeid to ceate box whusker
plots he command ccun 0o% h in a Vcutjek
CCL
oF CwCUS to visoauize simple or ayuite Compuex
dota
Basic BoxpLOks:
he touowitnq example shous a simple data
ProuTe Compased OF tuwo Coumung:

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

Hne chats Usinq Normeric Data


JF he Htme vavy able you ve co rded is in
tthe FoYm oF a wmeric vuyable yo0 Can
VSe a requla plotc) tonmmatid Yo0 CLn.
pe Fy ditterert ways to pYesert the,data
SI nq ttie tupe instructiotn-
Che type =Jnstructidn Cun altey tthe way
Duta is drcuwn on tthe plot ue.
Jpep polnts otuty
ypeb' polrts with ine segmerts
between
Hpe "l ines Segmeruts auone wittnO
Potrnts
Epe 0'- ne6 Overplotted witt poitts,that
t6 to gap betuween ttie une

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

Cach itet is represented bya


6ice oE
the bigger the suce 1 the, bigqer tthe
Prethe
Contribution to tthe totel Saales J a simple
terms
Cerms,tie pie chaLt takes a Serieg oF,
dauta determines the propOrtion ot each
tten vepresen
Item towand the total old ctien vepre set
these as ditrerent sices OF the pie;
Lhe pie chot /s ottnotuy used to disp
PropoYtioncu data You CLti Cecute pie chatts
UsItlq tthe pie () CoTUTLand
>dutqI
tJ 3 5 75 3 26 85 6 8
dcuta 8
OJ "Jaun '" F e d " "Man" "Apr" " M o y " J u n "

Juu" Aug" usep" oct" NOv" upe'.


pie cdctall labety :data 8)
pc cC'grayuo "gayso' 'gayb0'gruyw)
ruy go "gruy eo).
>pie caata tl; oLbels= dcutcLE1 COlz pC Uockwise
TRAUE.Finut aungle =L80):
Mey
APY
Ju

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

You might also like