Git Product home page Git Product logo

ddiwr's People

Contributors

dusadrian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ddiwr's Issues

Consolidating metadata for a collection of files

Congratulations and many thanks for this great tool @dusadrian !
I undestand how to use the convert function to produce DDI files with a one to one correspondence between source files (in Stata for instance) and xml files. But I can't figure out how to consolidate it. Here is one reproducible example using the survy models proposed by DHS:

# Install the latest version of DDIwR
remotes::install_github("https://github.com/dusadrian/DDIwR")
library(DDIwR)
library(tidyverse)

# Set our variables to acquire the data
dhs_dir <- "test/"
dhs_models <- c("zzbr62dt.zip", # Births Recode
                "zzcr61dt.zip", # Couples' Recode
                "zzhr62dt.zip", # Household Recode
                "zzir62.zip") # Individual Recode
dhs_base_url <- "https://www.dhsprogram.com/data/model_data/dhs/"

# Acquire the data
dir.create(dhs_dir)
dhs_urls <- paste0(dhs_base_url, dhs_models)
dhs_dest <- paste0(dhs_dir, dhs_models)
map2(dhs_urls, dhs_dest, download.file) # Download
map(dhs_dest, unzip, exdir = dhs_dir) # Unzip
stata_files <- list.files(dhs_dir, pattern = "\\.DTA$") # List data files

Here I have 4 stata files that correspond to different questionnaire sections or different formatting of the same data. I would like to make a consolidated DDI file out of them. Here are two questions:
How can I use DDIwR to convert them to children of a parent common object?
How can use DDIwR to add general metadata to document the Overview, scope & coverage, sampling... and other attributes common to all the files?
Thanks in advance for your feedback.

Minimum supported DDI Codebook version

Hi, thank you for the useful package.

It is stated in the DDI website that DDIwR is used to "create, edit and validate a DDI Codebook version 2.6, using R script commands.". However, in the package documentation it is hard to find references on which DDI versions the package actually supports.

In getDNS() function in internals.R the package seems to look for version 2.5, otherwise it throws an error:

DDIwR/R/internals.R

Lines 784 to 790 in 34dab97

`getDNS` <- function(xml) {
xmlns <- xml2::xml_ns(xml)
wns <- which(xmlns == "ddi:codebook:2_5")
if (length(wns) == 0) {
admisc::stopError("The XML document does not contain a DDI namespace.")
}
return(paste0(names(xmlns)[wns[1]], ":"))

This was a problem when a certain data repository was still using DDI 2.0, which is valid DDI but not recognised as such by the package. However, it is reasonable that the package supports only DDI 2.5, I just wish the package was more transparent about it.

In DDI_Codebook_2.6.R DDIC object is defined, which is used in checkXMList() function in internals.R:

DDIwR/R/internals.R

Lines 263 to 285 in 34dab97

`checkXMList` <- function(xmlist) {
nms <- c()
extractNames <- function(x) {
if (is.list(x)) {
nmsx <- names(x)
indexes <- seq_along(nmsx)
wextra <- which(nmsx == ".extra")
if (length(wextra)) {
indexes <- indexes[-wextra]
}
nms <<- unique(c(nms, setdiff(nmsx, c(".extra", ""))))
lx <- lapply(x[indexes], extractNames)
}
}
extractNames(xmlist)
if (!all(is.element(nms, names(DDIC)))) {
admisc::stopError(
"This XML file contains elements that are not part of the DDI Codebook standard."
)
}
}

When I tried to use getMetadata() function on a DDI-C 2.5 file it threw and error on lines 280-284 because the check does not accept p and extLink fields in my file although they are 2.5 namespace. However, at least in the case of ExtLink there is a deprecation note in the R-file:

"Note also that the DDI contains a linking mechanism permitting arbitrary links between internal elements (See Link) and from internal elements to external sources (See ExtLink). Note that the use of these two elements has been DEPRECATED in version 2.6."

However, when I commented this check out the getMetadata() function seemed to produce a sensible result without errors. Also with DDI Codebook 2.6 still being in draft phase (?) this check seems to be too stringent - or that the package only supports version 2.6 could be communicated to the end user more explicitly.

retroharmonize

Hi, I think that we are working on very similar issues, and solving similar problems. Do you think somehow we could harmonize the retroharmonize package and DDIwR?

get started guide?

Hi is there a get started guide for this package or do you recommend just using the StatConverter package?

(we want to generate a DDI codebook from our data for submission to ICPSR)

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.