The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Weighting data » How to Weight Data in R
Re: How to Weight Data in R [message #771 is a reply to message #706] Sat, 14 September 2013 11:44 Go to previous messageGo to previous message
Trevor-DHS is currently offline  Trevor-DHS
Messages: 788
Registered: January 2013
Senior Member
Hi Onetwo,

The warnings you are getting are because R converts categorical variables with labels into factors, but some variables have the same label for more than one category. R appears to convert these into a single level in the factor it creates. Some of these cases are because there are blank labels defined, and so all categories get converted into a single level in the factor.

You can avoid this by not converting categorical variables into factors. You can do this by using:

mydata <- read.dta("c:/Births/CDBR50DT/CDBR50FL.dta", convert.factors=FALSE)

and then convert any variables that you want to use into factors when you need them. This will avoid the warning messages that are produced in the conversion process.

Cheers. Trevor
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Pooling 3 rounds of DHS Nepal -- weights?
Next Topic: Applying weights for HIV Prevalence
Goto Forum:
  


Current Time: Thu Apr 18 04:24:14 Coordinated Universal Time 2024