forked from litalbarkai/open-redatam
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sending to CRAN with fix suggested by Ivan Krylov
- Loading branch information
1 parent
bbb6524
commit 6f5fcce
Showing
12 changed files
with
94 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
.vscode | ||
dev | ||
inst/extdata/galapagos | ||
src/*.o | ||
src/*.so | ||
src/redatamlib/*.o | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# the Galapagos census was downloaded from | ||
# https://redatam.org/cdr/descargas/censos/poblacion/CP2011URY.zip | ||
# I agregated the data to test the code | ||
|
||
# read DICX | ||
# when converting the original DIC to DICX in REDATAM 7: | ||
# 1. it doesn't include all the labels | ||
# 2. it adds MISSING and NOTAPPLICABLE to the labels | ||
# 3. it creates problems with lower and upper case (e.g., CG150001.ptr and | ||
# cg150001.ptr) | ||
|
||
test_that("reading works", { | ||
zip <- system.file("extdata", "uru2011mini.zip", package = "redatam") | ||
|
||
dout <- paste(tempdir(), "uru2011mini", sep = "/") | ||
|
||
if (file.exists(dout)) { | ||
unlink(dout, recursive = T) | ||
} | ||
|
||
# unzip the file | ||
if (!file.exists(dout)) { | ||
unzip(zip, exdir = dout) | ||
} | ||
|
||
# find the dictionary | ||
dic <- list.files(dout, pattern = "\\.dic$", full.names = TRUE, | ||
recursive = TRUE) | ||
|
||
dicx <- list.files(dout, pattern = "\\.dicx$", full.names = TRUE, | ||
recursive = TRUE) | ||
|
||
# read DIC | ||
|
||
res <- read_redatam(dic) | ||
|
||
expect_type(res, "list") | ||
expect_equal(length(res), 3L) | ||
|
||
d <- res$sexo | ||
expect_true(is.data.frame(d)) | ||
expect_true(is.factor(d$sexo)) | ||
expect_equal(dim(d), c(38L,4L)) | ||
|
||
daux <- res$sexo_labels_cuenta | ||
expect_true(is.factor(daux$cuenta_description)) | ||
expect_equal(dim(daux), c(2L,2L)) | ||
|
||
# read DICX | ||
|
||
res2 <- read_redatam(dicx) | ||
|
||
expect_type(res2, "list") | ||
expect_equal(length(res2), 2L) | ||
|
||
d2 <- res2$sexo | ||
expect_true(is.data.frame(d2)) | ||
expect_equal(dim(d2), c(38L,4L)) | ||
}) |