dusadrian / ddiwr Goto Github PK
View Code? Open in Web Editor NEWDDI with R
DDI with R
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.
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:
Lines 784 to 790 in 34dab97
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
:
Lines 263 to 285 in 34dab97
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:
Line 794 in 34dab97
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.
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?
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.