0 ratings 0% found this document useful (0 votes) 20 views 13 pages R Programming Notes
The document provides an overview of using R programming, focusing on command line interface, batch processing, and data manipulation techniques. It covers essential concepts such as data types, vectors, matrices, and functions, along with examples of command usage. Additionally, it discusses package installation and the importance of tidy data for analysis.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here .
Available Formats
Download as PDF or read online on Scribd
Carousel Previous Carousel Next
Save R Programming Notes For Later Module ~ “A va BB
Uwrrope cTON Te Rk.
x Command Line Interface
# Bosic way ts interact wrth R
EONS enteted Of ib NS
= RR wter preter as
Noli d Ro wlll execute it yetuining She
, ' 8
vesule La the Comm ank conepic!
eg >in4s
olp Cig 20 +> Mesos clp 18 o vector
vector > cellectton of data as on auay-
x Commann line editing -
+ Gp & down Quow Keys
+ Most Import tance line edits ae upd
down = auow keys
Lp avou lets get look at eoxclyet
Commands
+ down Quow \ets yee look at lates
Commands .
Yistory Cd piesicsly typed comma nds.
x Batch Mode
RR pwrides GB way ts tao lage sed
of cemmands seguence 4 Save the
to og Tle tho ‘s calles
Xesa its
batch mode.
$R cmd BATCH gereraie guaphs .R ~> To execute ‘the
codeoe Ms used Oo
named =”
on
+ Pstudio 19
emucnment
~ Ris used on
Temportonte In Batch Pro cessing,
jnteacton 4 makes
more efficent te sun
x RB Poctoges
fomst
8 The duectesy whee
ie cathe Ubiay,
‘ogg poe 8
omer see tale
Vibra, ie
Syoron
»
we
tl. pecrnges Cag hha?)
Lebears Cag 3)
®
Datatarle
eas the fastesd
hondle
data — manipulate
400
5 ng ice
Syoros
lnstall - packages
Kibtewy Cate . table)
esoke= ger
Joe > Inielligen +
ap ly
ne stawetesl , big dase
Batch processing aeqund °
wepectatve task
Packages cae calention
dota Sh Compiled code.
Meas bas on
aoe on Abe gemma: of grapes
poctayes
Nast — emoun t :
Co date fable")
4 Caate fiame 5 ays)
which 15 sed for
Ik iy the POCkoges
date mane palabien by powding-
Dffeent se of verbs ke Select
auongy CD, summasse, mutate)
Jyptos
Wwstoll - packages Co apply?
Vieiaeyy Cagle)
TidyR
tidy dats
ie bes to ceete
Tidy dots consists of those dataset
Ube eve cal acts as ingle vi
2 acks a sing! jalue,
Whee every Hou Ban — obseqvation &
Gres Column 1s a vaualle
Syptex
Install pactoge CNay ”)
Vbiaay, Chay ®)
con be sek te build webs apphcatbons
lostalt po cta Ce ,
ges C Shing!)
Woacy er)Cory based gee’
. re pase ordi
g Potty
tee gat Vbiaiy GE FE cheery
gor 2 dats spt tng, ei
3 Taining model
1 Syptoe 4 Resampling fou model Training 9 .
Install. packages potty) Za ante portance estimation = ‘
x o
Wiaeg Got ly? Install - package Cearet)
A kiky | \yasiables
o tk Is the packay os | 1 -
see eh package mostly ced for | | quables ae Containedg fox stoung, date
ee ig eee FON PBA Cleabens | Values
+ Syn te | | RR does: pot. Teguxe — Variable times
Install peckage Cknity’) ty be _ declared &
Woieey Cina) © Thee aie, ur bes of ways assigh
Bombe 3 a vie «= @ ° vatiable \
Has cccted for ding machine be + The _valid assignment operator .
. a B Teathing (ted
Byres i he ge
x ook
Natioble | nome woot
Shove Dome Cady)
Install. pockages C*miv 3”)
aie
name betel)
= Vaiioble heme
Womy Cents 9
1 x
G Boost Cperformance & 5 on descatgtne name C ager
oR cn imple to Vatable nam. muse Stare ith letter
implementation of quadie » Natable 7% We wi Jette
« Boosting Faamesou's a ” and can be a Combi nation of letters,
BstalN poctages CX Boost!) digits, posed Ce) a endescore C2
ost!
fay Go test) cp id start with. pede, TE cannct be
followed by a dig
» & vatiable — hame cannst Stace Gith @ number ot
Wo Can A "Tastes
et - Cl
. Classification A Regiessien Tawing
SE Pledes the trols for the follwing prot Nit able nomes
«Fellows te
P ~ Nea ,
aie - case «= sensenGve= Peed Vans aanmt
wvaulable
> Assign faction
fuign fonction weed OD WAUbles
> assign Cy)
oT
ow
= Removing Yai ables
The Keyword aemove , oO 7 is wed to
a votiable , dhs EES OP memoey in R
= Gas bage Collection oT ge which Velease.
unused. Perm, in the operating Septem
Datotypes
rhe ae some basic | dalatypo | SR in Re
1 Name Clos S578)
+ The most tommool: used — Aatatype iw R
& handles integ es and decimals, both
gositve “Ob negate rhumbers) And © evo
Lig. numeric 1 i ase — £0 test erheothu
ce Vatigble 1s qumede
Inte gov
Thee
z tate ‘a, fo whole number
“ an \otejes to the vatiable
is nece
_ectessany 48 append the Value
with on IN
\S. Imtegen fi
Fan
‘a ction the .axd to check
4» Durpencally Tiwe 1s Same as
°
B vector
© lbs Tae 2 collec ten,
wreathes the valle hs. integor:
“Stetituca |
x Carecettelet— Frongre:
chavocter
+ Choractey Csteing) dota ype is Used
veyy commen in statitiscal Aina lyst?
logical ©
+ logicals tea of xepresenbing Amie that
cah be either Rue fer a(n 2
L ana alae iF
We can Hse class Fenetiom CD *° check
the olatetype of a avioble
so find the length of @ Character Cot
nomerc) aa the meme fangtre n
of Clements a aol
+ oe EYP
the same , CAFEQHY oS 4s cueate a
she most = Common
vector with veetor S&S
The C Stands of Fox comprte: combine
because rmultiple clementy ae combined ints
a vectos
sae e Cas?
ox
oly
LA aay
GE coe great C29
Ho gerciate a se guente Conse cu hve
numba tn tithes ditecten
Sire
oleC3 Vad si WHS
Ris a vectoneed Vonguage that means
epetotiens Owe opplyng ** each element
of the verter automatically , ithout
die eek to 1O°P trough the Vecter
-F Neceow Operabons
x tMotespication C *)
pxas
ox
2 36 3a 15 18
x Addit: C+} |
> 45
>=
cg. 67 8g 40 “ue
x Subtvaction C-?
P2-4
oz
DR Nc BN ot
CQ -3 -2 © 3 =
i «ME ue have «= vertex of egal
mgt each, of them cores pending
tlements can be foyer
4 Pzry
opusted an
xz>tr274
d >free
then opera ting on wo vectors ubegual
length , the shorten Vector get vecgcle®
ie Clements ave vrepea ted in oder
unl they hove been sale sith
every element of vec tox
if the bagex — vectos we onrke which
not a mutt ple of shorter OP,
a waning is giver
Sp)
paw aes
2 vata
a |
Individual alements of 99 ;
done using C3 Coguave brackets)ay the vera /ting
wheather A
: x “ ae tue 1H the OU Somtey
ler
any! dam hon ches oy ebernents
’ Y
is HE
2 ey Cx?
? tale
zat Cxey)
2 CAlsE
+ factors
Pea eo tehey batall Crete, Hockey?)
> prtacky as. tecrr Ces)
2patector
a
Aflex Punting cro element) of gefectrs
ae ole punt the — Revels of 92 feck
+ The let) of Rechy we
of thd techy Vetiable
-Ris ging cach wigue Volee of 2 tack
2 cnigue inkefes
+ Bs cay be Seen with BS umecie
anigve Vole
7 Sota home
Ro dotatiome a Sihe
7 4 exce! —sprecdsheed
BS Colimns ond Leues
- Each etlumn sa varoble and each
was “> * eb se watuns
wrth
Eock celuwn is a vector eoch of e
4a> PM oame — ‘ength -
Elements must be Some type
fy Pe se Cy) ;
7g = 6 GH s)
72 *
Co vecney",” Febbal Socket wre gban
“BashetbaW”, “Hondball” *kabedi * “yENo),
Pato”, hess!)
date ame <2 ye
wor CeF ) 2
~ go8 Birra ech
—4 hockey
o - 3 Soxttal!
se * ~2 cucket
° Bestetball ~
- Voretbal
. . \oboa,
# 3
- Poio
. s Shes s
DE Cio)” |Dimension
= reel Tuncten
date fame
Fan ction
dotefismes
of a Actafame
star Column
for no of
fo
Syotex — 0 col C4 I73
= neowlt)
[7%
2 Bim C Omension)
cUlemns in
ne ot Cows in
x The functon olim it sek to get
He dimension of the dota tiorme
dim Co¥#)
> head function - It's used tO pod
the fut few soos in a af
Syo tex
heoa (OF)
> tail function - lt is used to pant
the last few fous in
Syrtex
tail COF)
Detafiame allows
Chrments by treiv pasthon
as
to
using
a data fiam
access
yuo
andivieksa!
haces,
°3
¥
1 e
|
x
°4
> oF [30]
po -2
14 specify more than ore
columo used a vectow
cor [e C35), |
fow Column
OJ -2 9 ciekes
[1 0 Basketball *
To acces on eatin “our specity tod
c
while. rot spectying 94 cohimn
>or C ,3)
mee OF at
por 1,4 .
List .
To sie any ne ems of ang
type
fp Bt cm conto — of mamene characte?
oem of te B40 OF clatafiame Oo
thes Atteach —mpumens
a —ekmend—od
we
tsa < (WSE C13)
fista ce tist Ce cis)
ee ce Casa) 208)
ead efenent Fete ojement +s
Ghee
ehrced OF = Hh lish,
tee tncton becom
ofp ¢ .>Cceod
op 1
>Ce232
«
ol 4 Ss
Be access 00 Indevidual ebment Of
Wt we we double spuare biechers
to cece specitying — Bither’ tbe. element
Aumber ot - name.
WMidtices.
Be odd om ehkment toa lst by
wig an index, ther ches rot acti
“Yengths of . list J
op
OF 3
list Cou] £6
2
Matices
———
€3
be cig‘ sevites ON" datetime intiet HHO
lamns
ath row 4 co! \ cteept that
mec rangula’ mast be HO a
evay 7g :
4gpe- v
Nati muHipicabien is only possible if the
po of colomns ot (the left hand
same as no of ows
clement
roatiix te be
ep de Bigh hanak mats
Matix Swnctor is bred “+0 create
matuices
Qe Matia Cire ,ncowa2)
Bematixn Cer, nows 3)
ee
3Aare : 1 €3 re a
tne dirmessiovel Yectoy ib PaGaestar) wot 7 as
‘ 3
ior ih um“! *
Yeaa pt ae. Mod vidoes
co
4b mash be
elementi access
+ te tut element
pina. Cobalt) roe ae
Selse if Cx==kk) |
using ewe Sector,
i vow sndet , Abe
reodek
|
|
i
oO
| Sere BGreg BP
secon 14 e0hnn - A
W omy cboeton is ued ooo peind C° good eye’)
ana ' ' , 3
he huey Cla , 700 =e)
“4 : : Vouint Co confuses”
Ge Any C5°% onus 3) i
Sek : *
> Cantiol Stetements
: | bint eum) a“
Condat statements alloy the flow of
f
Oi flogitmeming ond cause Afferent thing,
to beppen depending 00 the Values’ of x Switch
test
- ce foe) ave) misple] come | Slowet
KF ond Else netic
- ity ole f egecty can be nehBcet-
he most common dest fs. the iF Fl .
' : : wis ty whee HE HE Se Thee
mand . if eee essen tal Says io
: : 2 ¢ : The FuSt games ts The lee
WP something 1s te | then pe form 4
Some action the : a . ‘ esting:
ee + Subseguen + — argurrent or @ particu low value
fom nah act
: | uber gravis be the vevale.
. andx Wiebe
wm 4 Khe
+ De fst agement | the condition b be testes
the Second oagumen Qs the sttuan value if
Soo ee
iy te, scum, vole 1 due, false :
member £54.
wee if fanction tn Exce)
> Prete Ctotest=a1 tote #3 tated)
G syptox
pen iP OE Ches + iyes no)
Test. A bgeal condition et capes ton
‘tha + tetuny MoE o FALSE’ for cach
element in the i/p vector
Yes, No~ “The
candition
Noe rehun When
i se 1S RE et Peas
f
a 2 = Cs eee?
Feuie © ifelse
Print Ciesut &)
ofp
ED Nye
& Now -pouitivg
(a> o,"Tostne “ge Ht
PHBVE Nop gos ve!
Positive”. “Ruitaye!
7 Functon 91>
+ fanction ts a block of code tat can be
called multiple times fiom. different
part of BR ux pogiam
1 AR -Punction in BR bepically consist of
Functor name jagunents and Ronctin ty
ao = fanction “C9 "
{ pint C tele wood *)
J
—> loop
loops ate used i, waa On:
elemestg ot & cectos | Wet &9 doaiaflame.
\) for loop
So 6 ite)
ree Gin.
Gud pot 1s the,
be volus 7 dhe
variable fe
The
iteratively asig?
ea fe ee OE
= The sear" put sien ply
. “gs in vectow”
de Wd
“ ndicating
in
"The dha quid te 09 vectorof voles of MU
2) while lop
o% urile 6x ee |
Iyer
7
He simply suns Fe eal code
Function — Aigumend
Bee ae “aadka inside the
ction dectava ies
parameter ofModule -#
CY Mhelte ated | today's Suoday”. ; .
Wat
Reading Anat a ‘ .
; Default Aigument ;
Reodligg CSV 6 > Helle passa < Functor Cut slats dee? )
. do cook ote L :
Te bert ny? pant Gantt Co tello rf 3 ses fut, lar)
Co ee ee y 7
nop
ee hulle. person Cuca")
dable with the sep augument Csepacon) Cry “Helle yaud Doe”
peer $s be comma hs tenure q
of using ead. table is a datafiame >Hello. pesen CFued , “lander”
Cyt elle Tared — lander”
Function Aigumens Fondling csv .
: dye
These an adder imide the paamesthasis |
ot function declaration
ead. table (Files lel , header ~ TRF, Sep="2
tead. csv Cfile= ail, header = TRE)
Spistf - ve ceed to Pe fod
Gigunent a @ Sting with special
tip chuectes Gd Sabieguent Offiments ‘| ci
let Gil bed suntituted inte th | sod C+)
H e
Spedal input Character > heat “function used
a dotafianme
to puiot
fhe fist Ru tows ir
in
SB! SspnkE Cette os %
os", “Taxa”
CD “hate oreg” o + the fist Gagument is the file name
4 quotes unich peed to be ead,
2
The secon aigement 13 heads wndica tes Het
of te data hol the
spine .
Gnellg ‘ho S ede is ms? Sot
“ | ‘ We Ot ee
Teed! "Seaday)
S colima namea we
debit)
5 2 th fecks
1 he €
sepuotig tele colt
ata fl pony
. = Sp hectos ee
4 choiocte” cokes OG
; a one: smportant functions 40
4eoding lage e's are fal deléty
and Freak
+ Both ae fest and EH, neither
converts characten data to actu
Qutomet Cally
~ Aead_delim
ihe newt Re yeady = Pockog
«
omni of functors fou
Me
fead. dation fo teeding
delim Het
fic eeu OS™
+ The fe HE fish Bent will be te
full “ile Dame = OY Ol Ge te le
“ho be ead
2 The col = Nemes
eaguments 18 sere
Ste the by
Sree NG reir,
defauit we
fo
me
+ The veod - =
Syotom
Kibiay Cready)
£@ seeds delim ( files" OW 8//rew 2)
pe a Gb Ge
of datofiame
metadata
the column
rot HEY
fanction
et
that
visual change *S
the most
Show &
ig displagrege*
ee ore Hp
wif also
name $
Shaw
she farction vead_ c8v, tead- ¢S¥ 2 and
Se chen
semi colon «
i dunes WC comm)
foe respectively
= Fread
« oy deading «AF data gurckh Tread fiom
i ‘ Na el oes
dlata-table package
che fll file name Of ad ot He
fo be tead.
Ih beade aigament indicates det ane
pate fe ttt a
imiten
d sep aa gunents spect “4 dhe del
: +
fancten hos Sting as agen se
FASE by default.