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