[R] density plot for weighted data

r student studentofr at gmail.com
Tue Aug 2 19:11:42 CEST 2011


Like below?

plot(density(oh$FINCP,weights=oh$PWGTP/sum(oh$PWGTP)))





On Tue, Aug 2, 2011 at 10:06 AM, David Winsemius <dwinsemius at comcast.net> wrote:
>
> On Aug 2, 2011, at 12:51 PM, r student wrote:
>
>> I'm trying to create a density plot using census data, where the
>> weights don't sum to 1.
>>
>>
>>> plot(density(oh$FINCP,weights=oh$PWGTP))
>>
>>
>> Warning message:
>> In density.default(oh$FINCP, weights = oh$PWGTP) :
>>  sum(weights) != 1  -- will not get true density
>>
>>
>> How would I go about doing this?
>
> Wouldn't you just divide by the sum?
>
> --
>
> David Winsemius, MD
> West Hartford, CT
>
>



More information about the R-help mailing list