[R] barplot() x axes are not updated after removal of categories from the dataframe

Dieter Menne dieter.menne at menne-biomed.de
Thu Feb 12 14:41:43 CET 2009

R User R User <ruser2008 <at> googlemail.com> writes:

> I am plotting categories (X axis) and their mean count (Y axies) with
> barplot().
> The first call to barplot works fine.
> I remove records from the dataframe using final=[!final$varname == "some
> value",]
> I echo the dataframe and the records are no longer in the dataframe.
> When I call plot again however, the X axis still contains the removed
> category values albeit with a count of 0.
> How can I stop the removed categories appearing in the barplot? Are they
> stored globally after the first barplot call?

It has do do with non-dropped factors.

See http://markmail.org/message/qdgjpuzcfia3xm6p

Create a new factor with the levels dropped. 


More information about the R-help mailing list