You are on page 1of 9

Bahasa

Pemograman
Statistika
NUR AZIZAH KOMARA RIFAI
Subsetting
> x<-c("a","b","c","d","e")
> x
[1] "a" "b" "c" "d" "e"
> x[c(1,5)]
[1] "a" "e“
> x[1]
[1] "a"

NUR AZIZAH KOMARA RIFAI, STATISTIKA FMIPA UNISBA


Subsetting
> Games
2005 2006 2007 2008 2009 2010 2011 2012 2013 2014
KobeBryant 80 77 82 82 73 82 58 78 6 35
JoeJohnson 82 57 82 79 76 72 60 72 79 80
LeBronJames 79 78 75 81 76 79 62 76 77 69
CarmeloAnthony 80 65 77 66 69 77 55 67 77 40
DwightHoward 82 82 82 79 82 78 54 76 71 41
ChrisBosh 70 69 67 77 70 77 57 74 79 44
ChrisPaul 78 64 80 78 45 80 60 70 62 82
KevinDurant 35 35 80 74 82 78 66 81 81 27
DerrickRose 40 40 40 81 78 81 39 0 10 51
DwayneWade 75 51 51 79 77 76 49 69 54 62

> Games[1:3,6:10]
2010 2011 2012 2013 2014
KobeBryant 82 58 78 6 35
JoeJohnson 72 60 72 79 80
LeBronJames 79 62 76 77 69

NUR AZIZAH KOMARA RIFAI, STATISTIKA FMIPA UNISBA


Subsetting
> Games[c(1,10),]
2005 2006 2007 2008 2009 2010 2011 2012 2013 2014
KobeBryant 80 77 82 82 73 82 58 78 6 35
DwayneWade 75 51 51 79 77 76 49 69 54 62

> Games[,c("2008","2009")]
2008 2009
KobeBryant 82 73
JoeJohnson 79 76
LeBronJames 81 76
CarmeloAnthony 66 69
DwightHoward 79 82
ChrisBosh 77 70
ChrisPaul 78 45
KevinDurant 74 82
DerrickRose 81 78
DwayneWade 79 77

NUR AZIZAH KOMARA RIFAI, STATISTIKA FMIPA UNISBA


Subsetting
> Games[1,]
2005 2006 2007 2008 2009 2010 2011 2012 2013 2014
80 77 82 82 73 82 58 78 6 35
> is.matrix(Games[1,])
[1] FALSE
> is.vector(Games[1,])
[1] TRUE

> Games[1,5]
[1] 73
> is.matrix(Games[1,5])
[1] FALSE
> is.vector(Games[1,5])
[1] TRUE

NUR AZIZAH KOMARA RIFAI, STATISTIKA FMIPA UNISBA


Subsetting
> Games[1,,drop=F]
2005 2006 2007 2008 2009 2010 2011 2012 2013 2014
KobeBryant 80 77 82 82 73 82 58 78 6 35
> is.matrix(Games[1,,drop=F])
[1] TRUE

> Games[1,5,drop=F]
2009
KobeBryant 73
> is.matrix(Games[1,5,drop=F])
[1] TRUE

NUR AZIZAH KOMARA RIFAI, STATISTIKA FMIPA UNISBA


Visualisasi Subset
> Data<-MinutesPlayed[1:3,]
> matplot(t(Data), type="b", pch=15:17, col=c(1:3))
> legend("bottomleft", inset=0.01, legend=Players[1:3],
col=c(1:3), pch=15:17, horiz=F,cex=1)

NUR AZIZAH KOMARA RIFAI, STATISTIKA FMIPA UNISBA


Visualisasi Subset
> Data<-MinutesPlayed[1]
> matplot(t(Data), type="b", pch=15, col=2)
> legend("bottomleft", inset=0.01, legend=Players[1], col=2,
pch=15, horiz=F,cex=1)

NUR AZIZAH KOMARA RIFAI, STATISTIKA FMIPA UNISBA


Visualisasi Subset
> Data<-MinutesPlayed[1,,drop=F]
> matplot(t(Data), type="b", pch=15, col=2)
> legend("bottomleft", inset=0.01, legend=Players[1], col=2,
pch=15, horiz=F,cex=1)

NUR AZIZAH KOMARA RIFAI, STATISTIKA FMIPA UNISBA

You might also like