<br>
uplain aout dasa ypes wrth tnanmpls.
dele the knd of
Pgamning. cáa types
h the
iaesmaton Varia ble Can hold,
bong' numehe Cinclading tatyes), chomcter(teut). lagical
Chuelfals e), and Compler nunmbos ; each wrth
wth speale
Sxamples and uses.
Represents numerical values ncluding decinas.
Exanple: 09e <- 25.5 (Hexe Dumehc
howing he alve 25-5)
Vatiable
2.
numerie data sepesentng
decirmals.
Khole numbers wrlhout
- 1o L CThe " inditates l's an
Enample: numbr
3.
Chatocta: t
Used fox text data enClosed tn Singe
double guotus.
EXanmple: name H
Ammu
esents boolean values, erthes "TRUE" o'FALSE"
Erample: is- adlt e. TeUE
<br>
:
5. (ornplen
Pepresents comples numbes wnts sea! 4
as
inaginay ponls (ucing ";
(lample : Complen - num
iraginay unit).
num -Num 22 +31
2. Illusate abot nctons in
Funclton 5
in R Pog
rnmin2:
k Programming languoge hlhen you Tting a
functon he
nme an o
the frle io
ohich you are Ctatig the Rncton need not
be tbe Same and you Can have
moe ntions in R.
Pogranming a "uncton" o£
bock of sa
Code designed to perfesn aa speche task, okete
you piovide nput data Ccalled argunents)
finco pioCesSes
the functor rouce destred
uput.
It's a Teusable set of nstucfons that an
be alled multiple tnes
Code, PTomotng ganteafion ánd
aVbding
tepetten.
lypes of function in R
longuage
Butlt-io Function.
USer- dened Fnction.
<br>
Built-in Furetonin R:
Funclon ate the finc tions that
are alrady
Built- in
caisting in
R langu oge ond you just need to
Call -them to Use.
burit-o funclions Itke Sum ().
tHese we USe
min C).
Max( ) and
Example : inpat:
t# Find Sum oP numbss 4 to 6.
Riot (Sum (4: 6))
4 and G.
# Find of nunbers
Rint Cman C4i6))
OP nunbos 4
ande
Priot min C4: G)
(1) 15
(1) G
(1) 4
Vser- define d functons in R :
nctions tions that ore
Dset-defined ate the fnc
Cteated by the Uses.
the OOS king efers, defeutt Pateamlr,
patometets,
User dePines
op that User- delined Runkon. They Can be
etcs
ony used that Specifie code.
<br>
Enample: t#ipet:
4 A
Sinp'e R Rincion to che ck
e
Ven odd
whetber
eVen Od = tnc tion x) s
o)
Setusn c even ")
clse
Yetn odd )
Rint (even Odd Cu))
sint (eVen Odd (3))
# utput:
even
(1) "0dd"
3. [Link] about objefs ine Prgtanamig
Objcts in
e pregramming an "okjecf " relers to cny
that holds a value,
data shuctoe Cnd he
defeent types ot objects include :
Vectors Cafomte yecfors), matrices, oafa fromes, ls
Batos, an d more
Types o
of
There 5 bsie tupcs o objects
in the
e longuage
<br>
Iype s of objects
Vectors
Lists
Mattices
Data frome
Vectoss :
Atomic Vec fors are ONe
Df the boste typs of
okjec ts pgtamaing
Atomic vecfors can store homag eneous data bype
Chaiactar , doubles, tntegers, ,
Such as logrCal and ao
Complex.
A elenent vatiable is also eid to be
Vector.
:
List
another ype ot oyect
list ís prgtommig
ous
ltst Gan Contain hetiog ene data bpes SucA
AS Vectors oY ano ther tsts.
Maticas:
To store yalves 2- Dimensional aoy, matrices
aYe
Data, number of sous and Colurns ate detined
c)
the mtis functio.
<br>
artay c) function s used to cteofe n-diamensional
>
his Aunctioo ats inattrble aS an
and Ctectes require od. length ol
o each dimens ion
as Speified the atht butfe.
Data ftames:
Data fames are 2-dimensional ta bulas data object
in R pro gtarming
Dofa fomes Consisls
of mullipe Colums
each Colums
Yepresents Vectot.
Columns
in data frame an have drPerent
modes
of dat enike matrices.
thoo to decbe
Single tyPe Multíple types
Vectos
DODO
t Lis
2D
Matai
Dada Piome
Aay
<br>
(he date and ime funcions
4-
lou to declase
2tec) fnction in
Ri
i's use d to
yaton: date ()
Potamefes : Does not aaept any
Tatametess.
Enample inpet: output
*
DProom to ilystrate 1] Thu Jun 11
OL:2g: 39
2020"
caling hte c) Rnc tion to H
shod be
# Cument date
den and tie.
date c )
Sys. Datec) Function:
Sys Dote (o Rnction ts used to refrn the ysten's dab
yotan: sys. batecs
Patametess: Does not accept
ny porametcis.
erample : t#
inpt:
R progorm to illustrate
Sys. Date fu tion 1] 2020-Oô -12"
Calling sys. ete () funclon to
retun the System 's oafe
Sys. Dale ()
<br>
ys. time() in e:
[Link] ec
o Anction 1s used to Yefa -the
System': le ond time.
:
dyržn sys-time()
Pata mefers : Does not acept
Erample:
-# P Protam to rllustrate
#
Sys. time finction
# Glling Sys
timeo Ame hon to
# Tehon the system's dfe and tne
Sys- timec)
[Link] 7one)
Sys tine onc C)fnction s sed to rehiin the Curen
ime 20ne.
Syntan: [Link] one )
Paamtts : Does not arept ony Patameters.
Stonple: # input:
output:
Fogann to ilastete
functioo. 2]Etc lo TC
Sys. imetne
tine one () fnction to
efon the Curent time Zone
time zonec)
<br>
5.
oile R
piogtam denonstrate
o
bpeiator s
,
Casthmetie logral, tedasion at and.
asspoment petors).
Opaators:
(pesatoss aYe -6e Symbos diecding i6e
Compt er to peen vatious iods of
Opextions betueen the Opetands.
>
opetators Siolale the Votious modheaficd
lopical, Ond decision oPeations peoomed ona
Set off Compleu nambers, Satgas, and
AumeriCals izput opetonds,
R operotos:
R onajoy four kids of binary opaafoxs
Spptts gpaans.
between set of
ypes of the
peratoI
Aritsmetic Leg ical Relational Asignment
opatars opaatws peatas.
erators
<br>
Athmete opetotors:
Axitimetie cfoatrs malub using the speciied
bethocen opands, wwhich mnybe either
numbers
, oY vectors.
Complen
Stalas Values,
ase pci fosmed clement-wse
The R opeatos
at
the coSSpondng positions ok he vecfas.
Addition opetatot C+) Mutphcation opatorca)
subtiaction opeatos c-) Dsion opetatoC)
log icak opetators
nn Simulate elemert-wse decison
|Cogical opaotos
R
cpetafions, based on the speahed opetotor beti
wAch ate Hen e
Valated to
tie operands, Value.
eithey a
Tsue 0s fose boo lean
lement-wtse logrcal Aio opeiator AoT opetotos c!)
element-se legical OR opt Logrcal AnlD potalei
Relatioral opeiators t
The Reltoral ptos in amy
R
at element
Compatison
ptations between the CoTegponding of
the. opetands.
tess than Ce Greate than C)
>
less than eqal to e =) =
Giate thon cual toc-)
Assigament opatots:
Assignment opesatbus used to assgning
Maes to Vasioue aata objects Tn R.
left Assignment C<- oY
Le- 0T =)
>
Iight Assignnent or-s)