star_rating: User Preference Aggregation

Description Usage Arguments Value References Examples

View source: R/star_rating.R

Description

The function uses a simple method to calculate the aggregation scores of user ratings, which is described in Langville, A. and Meyer, C. (2012: 128). Input data can be stored in a sparse matrix. Suppose there are 100 films and users are required to assign scores. However, each user only watched several of them. Thus, when comparing two films A and B, the method only takes account ratings from those who watched both A and B.

Usage

1
star_rating(x, show_name = FALSE, check_na = TRUE)

Arguments

x

a numeric matrix, or, dgCMatrix and dgeMatrix matrix created with the Matrix package. 0 in the data means no score is given; and valid score values should all be larger than 0. The function will do NOTHING to check the validity. Besides, NA also means no score is given. If your data has NA, set check_na to TRUE so as to convert NA to 0.

show_name

the default is FALSE, that is to say, the function does not store and show candidate names in the result and you cannot see them. However, you can set it to TRUE.

check_na

if it is TRUE, the function will check NAs and convert them to 0s. If NAs do exist and check_na is FALSE, error will be raised.

Value

a list object.

References

Examples

1
2
3
4
5
6
7
8
9
# Example from Langville and Meyer, 2012: 128. 
# 4 films are rated by 10 users; 0 means no score.
raw <- c(4, 3, 1, 2, 0, 2, 0, 3, 0, 2, 2, 1, 0, 4, 3, 3, 4, 
    1, 3, 0, 2, 0, 2, 2, 2, 0, 1, 1, 2, 2, 0, 2, 0, 0, 5, 0, 3, 
    0, 5, 4
)
m <- matrix(raw, ncol = 4)
colnames(m) <- paste("film", 1: 4, sep = "")
y <- star_rating(m, show_name = TRUE) # winner is film4

votesys documentation built on May 2, 2019, 1:32 p.m.