Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for haven package #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

elio4sakk
Copy link

The folder "haven" contains the necessary files for testing the function read_sas from the haven package.


l_labels <- lapply(data_sas, attr, "label")

test_that("Column 1 label is correct", expect_equal(l_labels$ProductKey, "Product Key"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how haven labels variables, but would it not be easier to do
expect_equal(label(data_sas$SupplierName), "Supplier Name") (or var_label(...) if it uses the labelled package)
I would imagine that this more closely matches how it would be used in practice...


#compare column 1
test_that("Column 1 matches"
, expect_equal(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think i would be inclined to do something like
expect_true(all(data_csv$ProductKey == data_sas$ProductKey))

@aghaynes
Copy link
Member

Great that it worked! Do the tests also work via test("haven", download = FALSE)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants