Skip to content

Support keys and tests with items in different orders #62

@statisfactions

Description

@statisfactions

Currently QME ignores the names on simple keys and assumes they are in the same order as the test. Should at least throw a warning rather than silently renaming them in the same order as the test.

Unit test:

math_char = math
math_char[,-1] = apply(math_char[,-1], 2, as.character)

math_char_rev = math_char

names(math_char_rev)[-1] = rev(names(math_char_rev)[-1])

test_that("QMEtest produces the same full key regardless of the column order matching of the test and key", {
  
  normal_math_key = QMEtest(math_char, math_key)$key
  reverse_key_names_key = QMEtest(math_char_rev, math_key)$key
  
  sorted_names = names(normal_math_key)[-1]
  
  expect_equal(normal_math_key[, sorted_names],
               reverse_key_names_key[, sorted_names])
  
})

When I reverse the names on the test, it scrambles the key.

The culprit is a line in refine_key:

names(new_key) = names(test_with_id)[-1]

Relates to #58

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions