The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Dataset use (other programs) » Reproducing reports in R using Github Code
Reproducing reports in R using Github Code [message #25729] Thu, 01 December 2022 11:41 Go to next message
victor is currently offline  victor
Messages: 4
Registered: December 2022
Member
I am trying to reproduce some figures from DHS reports, specifically birth registration data.

Using this code from the github page, I should be able to do just that. https://github.com/DHSProgram/DHS-Indicators-R/blob/main/Cha p02_PH/PH_POP.R

However it seems that this code does not work. Am I doing something wrong?

The first line it already goes wrong
PRdata[["ager"]] <- ifelse(PRdata[["hv103"]]==1 , as.integer(PRdata[["hv105"]]/5), NA) 

using double square brackets is quite uncommon, but it should work. However addressing the hv103 and hv105 data like that is just incorrect. This data is spread across multiple columns per respondent, indicated by hv105_01, hv105_02 etc.

Hopefully someone know how to get this running.
Re: Reproducing reports in R using Github Code [message #25751 is a reply to message #25729] Mon, 05 December 2022 09:07 Go to previous message
Shireen-DHS is currently offline  Shireen-DHS
Messages: 140
Registered: August 2020
Location: USA
Senior Member
Dear Victor,

Thank you for your question.

It appears you are using the HR file not the PR file. The HR file is the household level data and contains the variables hv105_01, hv105_02, etc. to indicate each person living in the household (i.e. here the unit of analysis is the household).
The PR file is person recode file with data on each member of the household so the variable would be hv105. Here the unit of analysis is the individual in the household.

Please check that you are using the PR file and not the HR file.

Thank you.
Best,
Shireen Assaf
The DHS Program
Previous Topic: NFHS-5 Disability and health seeking
Next Topic: Difference DTA and SAV
Goto Forum:
  


Current Time: Wed Apr 17 20:39:42 Coordinated Universal Time 2024