The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » Water and Sanitation » error using R survey for urban sanitation
error using R survey for urban sanitation [message #13348] Thu, 26 October 2017 11:42 Go to previous message
dhswes is currently offline  dhswes
Messages: 6
Registered: June 2017
Member
Hello:

I would like to calculate the % of the urban population using a flush toilet connected to a sewer. For most countries, I can easily calculate this using the R Survey package, after inputting the .dta files. Here is the code:

country_recode <- read.dta(filename)
country_survey <- svydesign(id = country_recode$hv021, strata= country_recode$hv023, weights = country_recode$hv005/1000000, nest = TRUE, data=country_recode)
svyby(~hv205, ~hv025, country_survey, svymean)

For some .dta files, I receive this error:
"Error in sum(sapply(stratvars, function(m) !any(is.na(m)))) :
invalid 'type' (list) of argument"

Can anyone advise on what is the problem? For the countries I receive this error, such as Gabon, the recode file has values for hv025 and hv205.

Thanks,

Michael

 
Read Message
Read Message
Read Message
Previous Topic: source of drinking water - variables in IR and HR
Next Topic: Query on data inconsistency
Goto Forum:
  


Current Time: Tue Apr 23 05:19:12 Coordinated Universal Time 2024