#Actividad de R
#install.packages()
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
class(movielens)
## [1] "data.frame"
summary(movielens)
## movieId title year
## Min. : 1 Length:100004 Min. :1902
## 1st Qu.: 1028 Class :character 1st Qu.:1987
## Median : 2406 Mode :character Median :1995
## Mean : 12549 Mean :1992
## 3rd Qu.: 5418 3rd Qu.:2001
## Max. :163949 Max. :2016
## NA's :7
## genres userId rating timestamp
## Drama : 7757 Min. : 1 Min. :0.500 Min. :7.897e+08
## Comedy : 6748 1st Qu.:182 1st Qu.:3.000 1st Qu.:9.658e+08
## Comedy|Romance : 3973 Median :367 Median :4.000 Median :1.110e+09
## Drama|Romance : 3462 Mean :347 Mean :3.544 Mean :1.130e+09
## Comedy|Drama : 3272 3rd Qu.:520 3rd Qu.:4.000 3rd Qu.:1.296e+09
## Comedy|Drama|Romance: 3204 Max. :671 Max. :5.000 Max. :1.477e+09
## (Other) :71588
names(movielens)
## [1] "movieId" "title" "year" "genres" "userId" "rating"
## [7] "timestamp"
##TABLA SIN FECHAS NA
MovielensSinNa <- movielens[!is.na(movielens$year),]
length(MovielensSinNa$movieId)
## [1] 99997
length(movielens$movieId)
## [1] 100004
diferencia<-as.integer(length(MovielensSinNa$movieId))-as.integer(length(movielens$movieId))
print(paste("Hay", -diferencia, "películas con datos nulos"))
## [1] "Hay 7 películas con datos nulos"
##Peores PELICULAS
promedioPuntaje <- 3.544
MovielensPeores <- MovielensSinNa[MovielensSinNa$rating < promedioPuntaje,]
print(paste("De", length(movielens$movieId), "Hay" , length(MovielensPeores$movieId), "por debajo del promedio de calificación (3.544)"))
## [1] "De 100004 Hay 48433 por debajo del promedio de calificación (3.544)"