0% found this document useful (0 votes)
4 views12 pages

Assignment R

Assignment R language

Uploaded by

aroradoll210
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)
4 views12 pages

Assignment R

Assignment R language

Uploaded by

aroradoll210
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/ 12

ghs what

ae-1

Oded
wrich lenath
enampleforstuetue function
and takes tabte
O a Cortigeney
&hbw
withVaialbles
Output Centable
21413l:613,2|I5)
Certable)
Pint ( e-c( Vec eating fat
the tale
ay
2 1 you corwet
Vectos
Collectio
. ovtigeney
isnelations inContigeney
2 2 = Cortiqemey table
is
ca Gt oata. lLAeo LsUs
2 3 table Used
245 is it single. wsot
! the ave imto
of stUetwe to
(vec) eate talebetuwerr Qmd toIalles
I 6 tahle
simplest en-basic taslesatabte Heate dhow Data
coumns
a
dimeienal ?
the
nis Give
certiqmey data a
Vaia fumes
data s kBun
Javguage
com Grtigeny table()
table-tt
am diatrieramples
ty les Jhuy
abjot pesvectacs . amd
abgument butibrß
d
tasle data of
as
Comtigerey aMe vetos?
a Aonples to
yevem a - Wsd cuente
erm dn
R to
A-2

what Output example: for table.


Categoxical
vauiablea. example dataGeatingn
etion Random
duchby which aole
nolern df hasically we
alouss aHe the usll
Name to
Numbt Rishaw data
Cortable-table(df)
Contable) (
Porimt"Gende"
tablemmakeontiquny
licatioms
vatisusndomumbs
. the mbs. ,t eeate
c("Hash',"Rishov",
Name'
Ros"))"-fame
Genwaton etuUns (0ust
as e
MalGemde function
seaplain ta
n}) = ( oftable t
to c(" bles
enwote
inwth fenale Male'"
Contigenay
a toblefsm
R ?
etunns
ta yuom
is How bulan ()"
and erample
the ,"Male"
sandom t to sAult dr
dm Data
cilitated
ample is mechanism athe
ceate frames
," Cortigenty
(). Ferrale")) follauoing
of
the
16-83
i
munbus
in
Rarge :Range
/58
59 albu
doest
upetition
Staxting
value Value. 68 ': in
i I7: Range
Range nteqeu
50)
60 in
allow
uptition
in 20) TRUE) FALSE)
=1iaL- "83 Snteque
mar=20)
1 Numbe anden
(5, Handom Multiple
Rardorn -
6-419645 Juplact Juplace
<uni Random 2015
Random min=l9 19
(m=limin multtple
1) 20.61 151 , FALSE
8"651919
C1] ; 13115 l6 TRUE =
place
JHandornno (n=51 One 20 (o:20
One 7360 (1: (1: 1515 :
splae
uns
Gemwate Gemate
2. Qerate
Sarmple Qemsrate 20,
Sarnple
HLnf50 Sanple
61
12- (1]
for
ey [1]
C1] 3" sf
4 y.
3
and data to 1 Jhe
a enplain
for eqSyrta tame apply 1-
) Barne ppypackagc
ay the
apply
dample
matw)
peintCsample-
mati Prit
oppySarnplemati aPpy
utun vaxious
mangini
apply(z an
Asame (o fomilythis o
Ost
0%
.matirs (" Ot urotion utain
Vecto O
&urm the this Clectionapply
at lopply) 2- Vecto
aOSA unios
-matwe funtion
ofgumemt
along
olth deporrding
onth
ut - typ
HOwE') vaes lets andutunnfuncdions A
imthu he hulpa a
1 funcbion) takes
to funotiors
pat
(Cclt:16)inrow=
sun) us
obtaumed opplyapply
foum
matri wtain o in
funottonsusltthe R
Ba functiona o esntial R
functi'on orunction
data tos
3incol=t) vectat data
as
4
touppe) (marmus lagply
():") opely aftou data pint
("
:") ("original
data Pant
) ("Dolly"i"Rahul'"
Deepanshu' <-cmames Erample
(afun) oply Syrta
MARGON amud doesn't t ebject
St
iet foema the in
eutput yives ama input as
Vectoror ist, takes
a Jangunge Rthe n
on lopply heJemgth sarne the o
cuject
etunsa and sb<ects ist O
s ist applying us
talps
inLAPPlyOFuncton
t :- 2
47666666
369 4"33333 58 2
Coums acoss mBan l4J
55 55 55
ows: ao0LS Sum l4]
10 4 4 | 9 5 2 9 6 3
9 6 3 to 4 8 5 2
25
9 9 6 3l047 1
matie" "Sample 1]
Outputi
mean) (sarmple.matui
ai pply
Columns") aOAA (muan Point
Hitws
3
foeg
r objeet. Oukpii
Output
doesnt 3t a
Jemgth. Sapply "ovigiral
data"C43
with ist Co]
"Deeparshu"
"Raruul"
Doly"
RoHIT 4 LLY
Do1
DEEPANSHURAHUL
3 2-
Sample the iVector im data
Prirt
data. - an
dapplyPintkample ory the functioni
he
- med away aftee
("Oxigimal data tom or Ona
("data
(Jarple difoenee sapply()
data
<- fun)(x, magin: o
apply
of ist t
attee datan-frame fuame
an
funotion (0"
- mat hups
data data bing aay vectoe
dapply dt
:") as s "Rohit"
man)
is object
Y= (x- the inpit
or in or in
0:") Be
C(31
c(li21314 tymatic dlata
Rapplying
same language
pe and o
21412134 o uarres
the
516)3 eetukn dbject
as jive
Aomefunctiors
lappl)
taks and
5)
e 4 Ca)"original
data"
0ukput
opuatior
Opply s
ecisio
nditional ploin (tidyvoa)
ibrany
earmpe median
R Tapply(0
Ws 6 5 3 4 X
wit drre to ,
basd
tappy
Pu'ntl" fo min
vibus 2 2 3 Y
indenifun)
(diamends)heacPuid tappy ( 534
tatementa
hup tumetions eate functon
i
(dioarmonds each man
on of Avesage ("
aComoitiemal Heao a
tain
enomple? statisti
bubsetfacto etc)
allows of to dt
pice piee or cal data
43"
data") ot
each Variable a hulps
tioru statenentá i tor a mesuses
4oll
you dianords each vecto
sf us 34Y X
-wri 6
to the in sompute to
cutog ard ater
mak wsed feut
subst yectox (menn
diamond) thur furot
mean) i
in tt or
1

exampe
N5(enpassien)E R Crue
Print Print y jn
Srtanenpusor eranple
2<-1 00 m
else Print the Coaton
OY
aste (paste - byaces
else Condi else (paste mot
Statemerta-y
(u,
(x. Statememta. y in
/is tatements-y ton {3 JA
enpsssier :-
if
Condit'en (a"is
Cortimls true his
"is guuatoc
as ae
orditon qeater the contrsl
Coitor i-
eneeuted
thanthar1o")
st puovided.
ereCution
lo
") fails is
s therm l60Output
stuetwe
) is
but
sinilae lo) genter
ot
in
sdesthanQut6put ther
whenthe paunthesis
the
to checks
Statemerts if than statemerts
teat the
lÛ'" is
3
me-mtru
(2:1512)
for ( matix
the output Print
(i)
(iimn){ for exarmple Corolit'on
for erample Moteovet Nested Surta is fo
erarmplCnteax whe
(c leop
loop [Hic])
Print(mimim i-
While while
lnow
(m)))deq i Nestep
oops for
egln mested statemends st
Prt'nt(x) iteroted
whie Statememts.4 (value
Heacho is
(x<=
pession)£ cal a
loop (m loopsNested
mens "
6)
))i Output'
(4) ! in
wntil lops vecta)eecuted
£ es E "d"
aue
anothea C:7
condition C1]11 C1] I1] QutputCa] sirmila
aue £
atatenent 12[1 2 Used "e" tepeateolly
Kkind (1
3 C1
[a] to Cs)"""
]5 t4] ]4 inide
lsops
loop.
(5(1) C1] mariulate
is of
[1 6 impleto C11"g"
- losp
Ratesfed ]C17 [1] urtil
15
4 9 8
C1] eit
to
4 6
erample&ytanContrsl Sytag. be Repeat
thhuewhich
eranple
fure etwn
func()/ eult ueoL s
(epession
<- utwn ) statenenta
Hupeat t can oep
utwen
Zexo) (^ to in mo
('Negative
sutusn )ukuson
sitive")("Pofurction the
atotement epeat
of Ptnt(y
caling brea }k cany eit andb
eceuted type iteratedbreak
()¬ breaky3 condition
ution :-Jt
of
statement
tnction loop mrs
is to
beaK
uid erit mumbe
Negatve
l1)" "Positive"
l1[13 L1]output i
and to apeat
Zo" statement
omthe
etwn of
etuwrs times is
th loop. (oop a
can but
4 6
Whuch
Repeat
eample Cotrel
Sytax thue
be
fure
Kyntan etwen erample
Lsult ueo is
fuc 1) <furction
utunlenpuession ) statements
Hupeat t can loep
sutwen
Zeo') ( ("Positive")
utuen. to in mo
"Negative")
sutusn the
atatement Hepeat
of Portintl) cany eit bL and
catli'ng brea}y
k
eecteol type
iterated.break
(n) break y3 condition
¬ uncten :-
ofstatement
loop mary
t
is
nction to
beak
Negatve
[1)* 11 Positive"
l1] LiQutput
] used eit muntbee
!
ard to tom epeat
Zco" etwn statement
of
setuwrs t'mes
the sa
the
aop loop
anbut
lo
8
the Next
exarnple ehcecuting
Lfli2!6)¬ = ment
Puint i) toternpnt
met
iteva the
tthwe
tion
the
Cyele cuUent ment
statiments
dtatemerti's
[4]8 (17 6 (1) 2 without
[1] 10 ouiput
teation
terinnting and.
usedto
Cortinue,without
Akip
the

You might also like