tests/testthat/test-dropNA.R

library("testthat")
library("recommenderlab")

set.seed(1234)

## create a matrix with ratings
db <- matrix(
  as.numeric(sample(
    c(NA, 0:5), 100, replace = TRUE,
    prob = c(.7, rep(.3 / 6, 6))
  )),
  nrow = 10,
  ncol = 10,
  dimnames = list(
    users = paste('u', 1:10, sep = ''),
    items = paste('i', 1:10, sep = '')
  )
)


sparse <- dropNA(db)
expect_identical(db, dropNA2matrix(sparse))
expect_identical(as(dropNAis.na(sparse), "matrix"), is.na(db))

Try the recommenderlab package in your browser

Any scripts or data that you put into this service are public.

recommenderlab documentation built on Sept. 20, 2023, 9:06 a.m.