library(dslabs)
data(murders)
table(murders$region)
##
## Northeast South North Central West
## 9 17 12 13
#library(dslabs) No es necesario porque ya se cargó
data(movielens)
nrow(movielens)
## [1] 100004
ncol(movielens)
## [1] 7
class("title")
## [1] "character"
class("genres")
## [1] "character"
nlevels(movielens$genres)
## [1] 901
pop<-c(murders$population) #Vector
pop
## [1] 4779736 710231 6392017 2915918 37253956 5029196 3574097 897934
## [9] 601723 19687653 9920000 1360301 1567582 12830632 6483802 3046355
## [17] 2853118 4339367 4533372 1328361 5773552 6547629 9883640 5303925
## [25] 2967297 5988927 989415 1826341 2700551 1316470 8791894 2059179
## [33] 19378102 9535483 672591 11536504 3751351 3831074 12702379 1052567
## [41] 4625364 814180 6346105 25145561 2763885 625741 8001024 6724540
## [49] 1852994 5686986 563626
order(pop, decreasing = TRUE) #Indices
## [1] 5 44 10 33 14 39 36 11 23 34 31 47 48 22 15 3 43 26 21 50 24 6 1 41 19
## [26] 18 38 37 7 16 25 4 17 45 29 32 49 28 13 12 20 30 40 27 8 42 2 35 46 9
## [51] 51
pos.min<-which.min(pop) #Da el indice con el valor de menor tamaño
murders$population[pos.min]
## [1] 563626