library(dslabs)
data("murders")
#1.
head(murders)
## state abb region population total
## 1 Alabama AL South 4779736 135
## 2 Alaska AK West 710231 19
## 3 Arizona AZ West 6392017 232
## 4 Arkansas AR South 2915918 93
## 5 California CA West 37253956 1257
## 6 Colorado CO West 5029196 65
reg <- murders$region
frec_x_region <- table(reg)
frec_x_region
## reg
## Northeast South North Central West
## 9 17 12 13
#library(dslabs)
data("movielens")
head(movielens)
## movieId title year
## 1 31 Dangerous Minds 1995
## 2 1029 Dumbo 1941
## 3 1061 Sleepers 1996
## 4 1129 Escape from New York 1981
## 5 1172 Cinema Paradiso (Nuovo cinema Paradiso) 1989
## 6 1263 Deer Hunter, The 1978
## genres userId rating timestamp
## 1 Drama 1 2.5 1260759144
## 2 Animation|Children|Drama|Musical 1 3.0 1260759179
## 3 Thriller 1 3.0 1260759182
## 4 Action|Adventure|Sci-Fi|Thriller 1 2.0 1260759185
## 5 Drama 1 4.0 1260759205
## 6 Drama|War 1 2.0 1260759151
rows <- movielens
filas <- nrow(rows)
print(filas)
## [1] 100004
v <- movielens
cvar <- ncol(v)
print(cvar)
## [1] 7
class(movielens$title)
## [1] "character"
class(movielens$genres)
## [1] "factor"
nlevels(movielens$genres)
## [1] 901