如何通过另一个变量加权我的变量?
在 SPSS 中,我可以通过使用weights_by"来选择一个我想用于加权其他变量的变量.
In SPSS I can choose a variable which I want to use for weighting other variables just by using "weights_by".
为了我的学习,我现在必须使用 Rstudio.当我执行上述操作并在 R 中打开它时,它们的权重将消失.那么我如何在 R 中做到这一点?
For my studies I have to use Rstudio now. When I do the above thing and open it in R, they weights will disappear. How can I do this in R then?
类似于:
"weights(pspwhgt)" (without"") is not working for me...
我完全是初学者.我有我的可变性别,我想用我的另一个变量 pspwhgt 加权.如果不是数学或编程方面的天才,我怎么能做到这一点?
I'm on a totally beginner level. I have my variable gender and I want to weight it by my other variable pspwhgt. How can I do this without being a genius in math or programming?
与 SPSS 不同,R 中的权重应用于操作级别而不是全局.因此,如何指定和使用权重取决于您要执行的操作.许多 R 函数都有一个 weights
参数(例如 lm()
等).您可能还需要 weighted.mean()
等
Unlike SPSS, weights in R are applied at the operation level rather than globally. So, how you specify and use weights depends on what operation you want to perform. Many R functions have a weights
argument (such as lm()
, etc.). You may also want weighted.mean()
, etc.