svyby和空单元格

时间:2014-04-11 13:29:25

标签: r survey

希望这是一个简单的解决方案的简单问题。我有几个国家收集的加权调查数据。我正在尝试创建一个表格,按国家/地区显示具有相应CI和SE的特定调查问题的比例响应。在"调查中使用svyby"对于第一个问题,包似乎工作正常,每个国家/地区的每个因素级别至少有一个响应。

svyby(~V34c,~V4, design = data, svymean, na.rm=T,vartype=c("ci","se"))

以一般形式产生预期输出:

[国家,既不同意也不反对,V34cNo数据,V34cOverall同意,......]

AU-Australia,0.31459269,0.0425825851,0.2935771 ......

BE-Belgium,0.31884528,0.0895231917,0.2024003 ......

BG-Bulgaria,0.29237157,0.0649909093,0.4632688 ...... ...

然而,当在一些因子水平为空的问题上运行相同的代码时(例如,在#34;没有观察到整体同意"在保加利亚),我得到了时髦的输出:

svyby(~V34c,~V4, design = data, svymean, na.rm=T,vartype=c("ci","se"))

[国家,1,2,3,......] AU-Australia,c(0.165198816,0.026821016,0.734128167,0.073852001,0.012071501,0.006550439,0.014495680,0.008485131,0.141539109,0.013982390,0.705717158,0.057221449,0.188858522,0.039659641,0.762539177,0.090482553),c(0.155043789,0.043788518,0.744404801,0.056762893,0.006518719 ,0.003685319,0.007855954,0.004167357,0.142267333,0.036565425,0.729007414,0.048595024,0.167820244,0.051011610,0.759802187,0.064930763),C(0.305804298,0.016750805,0.461542910,0.215901986,0.015591287,0.004766330,0.016740671,0.014762079,0.275245937,0.007408969,0.428731799,0.186968842, 0.336362659,0.026092642,0.494354022,0.244835130),...

BE-Belgium,c(0.165198816,0.026821016,0.734128167,0.0773001,0.012071501,0.006550439,0.014495680,0.008485131,0.141539109,0.013982390,0.705717158,0.057221449,0.188858522,0.039659641,0.762539177,0.090482553),c(0.155043789,0.0373788518,0.744404801, 0.056762893,0.006518719,0.003685319,0.007855954,0.004167357,0.142267333,0.036565425,0.729007414,0.048595024,0.167820244,0.051011610,0.759802187,0.064930763),C(0.305804298,0.016750805,0.461542910,0.215901986,0.015591287,0.004766330,0.016740671,0.014762079,0.275245937,0.007408969,0.428731799 ,0.186968842,0.336362659,0.026092642,0.494354022,0.244835130),...

BG-Bulgaria,c(0.165198816,0.026821016,0.734128167,0.073852001,0.012071501,0.006550439,0.014495680,0.008485131,0.141539109,0.013982390,0.705717158,0.057221449,0.188858522,0.039659641,0.762539177,0.090482553),c(0.155043789,0.0373788518,0.744404801, 0.056762893,0.006518719,0.003685319,0.007855954,0.004167357,0.142267333,0.036565425,0.729007414,0.048595024,0.167820244,0.051011610,0.759802187,0.064930763),C(0.305804298,0.016750805,0.461542910,0.215901986,0.015591287,0.004766330,0.016740671,0.014762079,0.275245937,0.007408969,0.428731799 ,0.186968842,0.336362659,0.026092642,0.494354022,0.244835130),...

...

当我从数据集中删除违规国家时,代码似乎按照我预期的方式工作,但我希望还有其他解决方案。

谢谢!

0 个答案:

没有答案