rdhs icon indicating copy to clipboard operation
rdhs copied to clipboard

ribind_labelled () - advice on columns with all NAs

Open skuchukh opened this issue 1 year ago • 0 comments

Hello

I have a few questions on rbind_labelled()function. I saw this https://github.com/ropensci/rdhs/issues/9 though I have not been able to figure out my issues yet.

  1. I'm using both male and female datasets from DHS but of course some variables e.g. ANC testing (v840-v841) are not available in male datasets; or these variables are not available in neither in some old surveys (e.g. BJ2001DHS).

When I try to do rbind_labelled(ir, mr, labels=list(v840 = "concatenate")), I get an error message that the NA (logical) cannot be concatenated with character. Even when I convert the NAs to integer, and give some random, fake label to these columns via labelled::var_label(ir$v840) <- 'some label', I get an error:Error invalidate_labelled(): ! labelsmust have names. I was wondering if you have any advice?

  1. For concatenated variables, is there a way to maintain a variable name/label? Even though all unique value labels are maintained, the variable/column names seems to disappear.

Thank you so much!!

Salome

skuchukh avatar Feb 29 '24 14:02 skuchukh