I have the following dataset:
A1Ratings.csv (1.3 KB)
For each movie I am trying to find out the % of ratings >= 4.
tot_count <- data.frame(apply(movie,2,function(x)sum(x >= 1,na.rm = T))) req_count <- data.frame(apply(movie,2,function(x)sum(x>=4,na.rm = T))) count <- data.frame(tot_count,req_count,colnames(movie)) # Rename Columns: colnames(count) <- "tot_count" colnames(count) <- "req_count" colnames(count) <- "movie" count <- count[-1,] count$percent_rating = (count$req_count/count$tot_count)*100 # Arrange in descending order of rating % arrange(count,desc(count[,4]))
The output that I am getting is:
But apparently this is not the correct order.
Can somebody please tell me what I am doing wrong?