> p <- ggplot(m_rtn,aes(x=Month,y=Return))+
+ geom_bar()+
+ labs(title="Monthly Return")
> print(p)
出现如下警告,为啥呢?怎么破
Mapping a variable to y and also using stat="bin".
With stat="bin", it will attempt to set the y value to the count of cases in each group.
This can result in unexpected behavior and will not be allowed in a future version of ggplot2.
If you want y to represent counts of cases, use stat="bin" and don't map a variable to y.
If you want y to represent values in the data, use stat="identity".
See ?geom_bar for examples. (Deprecated; last used in version 0.9.2)
Warning message:
Stacking not well defined when ymin != 0
“绘图函数里的stat参数表示对样本点做统计的方式,默认为identity,表示一个x对应一个y,同时还可以是bin,表示一个x对应落到该x的样本数。”说白了就是,identity提取横坐标x对应的y值,bin提取横坐标x的频数。
资料来源:http://www.cnblogs.com/muchen/p/5279727.html
下面是R帮助中的说明:
“If you have presummarised data, use <code>stat="identity" to turn off the default summary. Sometimes, bar charts are used not as a distributional summary, but instead of a dotplot. Generally, it's preferable to use a dotplot (see geom\_point) as it has a better data-ink ratio. However, if you do want to create this type of plot, you can set y to the value you have calculated, and use stat='identity'.”
资料来源:http://127.0.0.1:10246/library/ggplot2/html/geom_bar.html