error using R survey for urban sanitation [message #13348] |
Thu, 26 October 2017 11:42 |
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
|
|
|