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

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

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.