Dear all,
This is probably a stupid question for which I have a solution, which
unfortunately is not as straighforward as I'd like. I wonder if there's a
simple way to apply a weighting variable for the cases of a dataframe (well
I'm sure there is, I just cannot find it).
My toy example:
Try this:
table(lapply(my.data, rep, my.data$weight)[1:2])
On 10/14/06, Adrian Dusa [EMAIL PROTECTED] wrote:
Dear all,
This is probably a stupid question for which I have a solution, which
unfortunately is not as straighforward as I'd like. I wonder if there's a
simple way to apply a
Thanks for this Gabor,
Sometimes weights can take various values, like 0.9
rep(letters[1:3], c(1, 0.9, 1.6))
[1] a c
What if the weight variable would be:
my.data$weight - c(0.4, 2, 1.3, 0.9, 1)
The way I found the solution was to compute the unweighted table, then find
the weight for each
Try this (and round the result to make to it comparable to your calculation):
xtabs(weight ~ var1 + var2, my.data)
On 10/14/06, Adrian Dusa [EMAIL PROTECTED] wrote:
Thanks for this Gabor,
Sometimes weights can take various values, like 0.9
rep(letters[1:3], c(1, 0.9, 1.6))
[1] a c
What
I missed your second question. See ?cov.wt
On 10/14/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
Try this (and round the result to make to it comparable to your calculation):
xtabs(weight ~ var1 + var2, my.data)
On 10/14/06, Adrian Dusa [EMAIL PROTECTED] wrote:
Thanks for this Gabor,
On Saturday 14 October 2006 16:52, Gabor Grothendieck wrote:
Try this (and round the result to make to it comparable to your
calculation):
xtabs(weight ~ var1 + var2, my.data)
Oh yes... :)
It was so simple. Thanks for the cov.wt() as well.
Regards,
Adrian
--
Adrian Dusa
Romanian Social