问题描述
我有一个
如您所见,y轴看起来好像包含根本不在过滤数据集中的电影(我是通过标题选择的)。
即使子集化后,因子仍保持其水平,您可以使用 droplevels
删除未使用的那些水平:
boxplot(rating〜title,data = droplevels(imdb [imdb $ title ==壮志凌云(1986),]))
I have a IMDB dataset and trying to make a boxplot of a film's ratings.
I've successfully loaded the dataset and tried to make the boxplot but it produced a really weird result.
It looked as it tried to make a boxplot for all the films and not just the one selected.
boxplot(rating ~ title, data=imdb[imdb$title == "Top Gun (1986)", ])
The graph produced:
As you can see the y axis looks as if it contained films that aren't in the filtered dataset at all (I selected those via title).
Factors retain their levels even after subsetting, you can drop those that are unused with droplevels
:
boxplot(rating ~ title, data=droplevels(imdb[imdb$title == "Top Gun (1986)", ]))
这篇关于Boxplot看到不存在的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!