有没有办法将 2 个“ftable”粘贴到目的?
我使用survey
中的svyby
来制作一些加权比率及其标准差和变异系数,我使用下面的代码生成一个三向表,它为我提供了男性远程工作者 Hombre_subocup/ocup
、女性远程工作者 Mujer_subocup/ocup
的 subocup
与 ocup
的比率对于非远程工作者的男性和女性来说完全相同。
tasasub_tele_sex319<-ftable(svyby(~subocup, by= ~ tele_sinco11 + SEX, subset(sd319, EDA >= 15 & POS_OCU != "Trabajadores sin pago"), denominator = ~ocup, deff= T, level = 0.9, vartype = c("cv", "se"), na.rm.by = T,svyratio))
tasasub_tele_sex319
并得到:
SEX_
tele_sinco11_ Hombre_subocup/ocup Mujer_subocup/ocup
No teletrabaja_svyratio 0.084149460 0.080230723
No teletrabaja_cv 0.001782653 0.002152965
No teletrabaja_SE 0.021184369 0.026834665
No teletrabaja_DEff 3.896438704 3.593164119
Teletrabaja_svyratio 0.036515518 0.027384514
Teletrabaja_cv 0.003075113 0.002250647
Teletrabaja_SE 0.084213867 0.082186856
Teletrabaja_DEff 2.325352651 2.039503624
但我还需要比率的总值(没有性别),所以我使用此代码并得到以下输出:
tasasub_tele_tot319<-ftable(svyby(~subocup, by= ~ tele_sinco11, subset(sd319, EDA >= 15 & POS_OCU != "Trabajadores sin pago"), denominator = ~ocup, deff= T, level = 0.9, vartype = c("cv", "se"), na.rm.by = T,svyratio))
tasasub_tele_tot319
>tasasub_tele_tot319
subocup/ocup
tele_sinco11
No teletrabaja svyratio 0.082730583
cv 0.001537011
SE 0.018578512
DEff 4.722529515
Teletrabaja svyratio 0.031475714
cv 0.001902234
SE 0.060434971
DEff 2.299934447
这将是没有任何层的比率值(一个简单的双向表)。
我想要做的是将最后一个输出粘贴到前者,这样我就可以在同一个表中得到男性比例列、女性比例列和总比例列,所以或多或少应该如下所示:
我不会请注意“总计”列是否先行。
I`m using svyby
from survey
to make some weighted ratios with their standard deviation and coefficient of variation, I use the code below to generate a three way table which provide me the ratio of subocup
compared to ocup
for male teleworker Hombre_subocup/ocup
, female teleworkers Mujer_subocup/ocup
and the exact same for non teleworkers males and females.
tasasub_tele_sex319<-ftable(svyby(~subocup, by= ~ tele_sinco11 + SEX, subset(sd319, EDA >= 15 & POS_OCU != "Trabajadores sin pago"), denominator = ~ocup, deff= T, level = 0.9, vartype = c("cv", "se"), na.rm.by = T,svyratio))
tasasub_tele_sex319
And get:
SEX_
tele_sinco11_ Hombre_subocup/ocup Mujer_subocup/ocup
No teletrabaja_svyratio 0.084149460 0.080230723
No teletrabaja_cv 0.001782653 0.002152965
No teletrabaja_SE 0.021184369 0.026834665
No teletrabaja_DEff 3.896438704 3.593164119
Teletrabaja_svyratio 0.036515518 0.027384514
Teletrabaja_cv 0.003075113 0.002250647
Teletrabaja_SE 0.084213867 0.082186856
Teletrabaja_DEff 2.325352651 2.039503624
But I also need the total value of the ratio (without SEX), so I use this code and get this output:
tasasub_tele_tot319<-ftable(svyby(~subocup, by= ~ tele_sinco11, subset(sd319, EDA >= 15 & POS_OCU != "Trabajadores sin pago"), denominator = ~ocup, deff= T, level = 0.9, vartype = c("cv", "se"), na.rm.by = T,svyratio))
tasasub_tele_tot319
>tasasub_tele_tot319
subocup/ocup
tele_sinco11
No teletrabaja svyratio 0.082730583
cv 0.001537011
SE 0.018578512
DEff 4.722529515
Teletrabaja svyratio 0.031475714
cv 0.001902234
SE 0.060434971
DEff 2.299934447
This would be the value of the ratio without any strata (a simple two way table).
What I want to do is to paste the last output to the former, so I get a male ratio column, female ratio column and total ratio column in the same table, so more or less it should look like this:
I wouldn't mind if the "total" columns goes first.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案是先组合,然后
ftable
。让我们使用内置数据集来完成此操作:它们具有不同的列名称,但我们可以修复它
现在将它们组合起来
The solution is to combine first, then
ftable
. Let's do this with a built-in data set:These have different column names, but we can fix that
And now combine them