Weighted mean for propoetions in R

Hi all,

I am wondering how I can compute the weighted mean for factored variables. All the packages I searched, consider a numeric variable not a factored variable.

I would appreciate it.

Farideh

For general R questions go to stackoverflow.com and use the r tag when posting.

Thanks so much. I will.

Factor variables are categorical variables. You can formally calculate the mean of such variables if you assign numerical values to each factor level, but the result will be meaningless.

Thanks for your reply.
My factor variable is smoking ( Yes=1 , No=0) and I would like to calculate the adjusted proportion of smoking versus not using weights group by City and using another medicine ( Yes=1, No=0).
All the functions and packages ( ddply, weighted.mean, survey package) I tried consider a numeric variable, so I couldn’t get the right answer.

0-1 variables are the only exception. you can recode the Yes/No values to 1/0 and then the mean value will be the proportion of Yes answers.

Please continue this on <stats.stackexchange.com>