Frage

In my lattice histogram:

histogram(~bill|group,data=mydat,type='count',nint=50,layout=c(9,3))

How to keep "bill" data before 99th percentile within each group?

War es hilfreich?

Lösung

You may want to remove outliers from the whole of the bill data. First copy your data into a new variable

    mydat$bill.cleaned=mydat$bill

then set the large values to missing

    cuttoff= qnorm(.99,mean(mydat$bill),sd(mydat$bill))
    mydat$bill.cleaned[which(mydat$bill > cuttoff)]=NA

Then you can display your histogram of cleaned data.

Alternatively if you want to remove ouliers only within each group. you need to do the same thing as above with an additional apply statement.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top