Professional Documents
Culture Documents
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"
> 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
> 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
> Games[1,5]
[1] 73
> is.matrix(Games[1,5])
[1] FALSE
> is.vector(Games[1,5])
[1] TRUE
> Games[1,5,drop=F]
2009
KobeBryant 73
> is.matrix(Games[1,5,drop=F])
[1] TRUE