<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
在ggplot2中繪製qq圖需要兩步,geom_qq()
將繪製樣本分位點,geom_qq_line()
將繪製標準正態線
geom_qq()
geom_qq( mapping = NULL, data = NULL, geom = "point", position = "identity", ..., distribution = stats::qnorm, dparams = list(), na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
geom_qq_line( mapping = NULL, data = NULL, geom = "path", position = "identity", ..., distribution = stats::qnorm, dparams = list(), line.p = c(0.25, 0.75), fullrange = FALSE, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
引數介紹
**aes()**中的對映引數必須包含sample,可選引數有group,x,y distribution
Distribution function to use, if x not specified
dparams Additional parameters passed on to distribution function.
line.p Vector of quantiles to use when fitting the Q-Q line, defaults defaults to c(.25, .75).
fullrange Should the q-q line span the full range of the plot, or just the data
注意事項
**aes()**中的對映引數必須包含sample
Using to explore the distribution of a variable
ggplot(mtcars, aes(sample = mpg)) + stat_qq() + stat_qq_line() ggplot(mtcars, aes(sample = mpg, colour = factor(cyl))) + stat_qq() + stat_qq_line()
geom_boxplot( mapping = NULL, data = NULL, stat = "boxplot", position = "dodge2", ..., outlier.colour = NULL, outlier.color = NULL, outlier.fill = NULL, outlier.shape = 19, outlier.size = 1.5, outlier.stroke = 0.5, outlier.alpha = NULL, notch = FALSE, notchwidth = 0.5, varwidth = FALSE, na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE )
引數介紹
aes()可接收的引數有:
notch If FALSE (default) make a standard box plot. If TRUE, make a notched box plot. Notches are used to compare groups; if the notches
of two boxes do not overlap, this suggests that the medians are
significantly different.
notchwidth For a notched box plot, width of the notch relative to the body (defaults to notchwidth = 0.5).
varwidth If FALSE (default) make a standard box plot. If TRUE, boxes are drawn with widths proportional to the square-roots of the
number of observations in the groups (possibly weighted, using the
weight aesthetic).
p <- ggplot(mpg, aes(x=class, y=hwy)) p + geom_boxplot()
ggplot(mpg, aes(x=hwy, y=class)) + geom_boxplot()
p <- ggplot(mpg, aes(x=class, y=hwy)) p + geom_boxplot(notch = TRUE,varwidth = TRUE,fill = "white", colour = "#3366FF")
ggplot(diamonds, aes(carat, price)) + geom_boxplot(aes(group = cut_width(carat, 0.25)))
p <- ggplot(mpg, aes(x=class, y=hwy)) p + geom_boxplot(outlier.shape = NA) + geom_jitter(width = 0.2)
y <- rnorm(100) df <- data.frame( x = 1, y0 = min(y), y25 = quantile(y, 0.25), y50 = median(y), y75 = quantile(y, 0.75), y100 = max(y) ) ggplot(df, aes(x)) + geom_boxplot( aes(ymin = y0, lower = y25, middle = y50, upper = y75, ymax = y100), stat = "identity" )
該函數是來自於qqboxplot
包,因此使用前需要安裝
geom_qqboxplot( mapping = NULL, data = NULL, stat = "qqboxplot", position = "dodge2", ..., outlier.colour = NULL, outlier.color = NULL, outlier.fill = NULL, outlier.shape = 19, outlier.size = 1.5, outlier.stroke = 0.5, outlier.alpha = NULL, notch = FALSE, notchwidth = 0.5, varwidth = FALSE, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
大部分引數和geom_qq()和geom_boxplot()中的引數含義相同
reference_dist 表示引數比較的標準分佈名稱,如果有引數需要有dparams
compdata 用於比較的標準樣本資料,是個向量
aes()函數中的y不可缺
library(dplyr) library(ggplot2) library(qqboxplot) simulated_data=tibble(y=c(rnorm(1000, mean=2), rt(1000, 16), rt(500, 4), rt(1000, 8), rt(1000, 32)), group=c(rep("normal, mean=2", 1000), rep("t distribution, df=16", 1000), rep("t distribution, df=4", 500), rep("t distribution, df=8", 1000), rep("t distribution, df=32", 1000))) p <- ggplot2::ggplot(simulated_data, ggplot2::aes(factor(group, levels=c("normal, mean=2", "t distribution, df=32", "t distribution, df=16", "t distribution, df=8", "t distribution, df=4")), y=y)) p + geom_qqboxplot() p + geom_qqboxplot(reference_dist = "norm") p + geom_qqboxplot(compdata = comparison_dataset)
以上就是R語言利用ggplot2繪製QQ圖和箱線圖詳解的詳細內容,更多關於R語言繪製QQ圖 箱線圖的資料請關注it145.com其它相關文章!
相關文章
<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
综合看Anker超能充系列的性价比很高,并且与不仅和iPhone12/苹果<em>Mac</em>Book很配,而且适合多设备充电需求的日常使用或差旅场景,不管是安卓还是Switch同样也能用得上它,希望这次分享能给准备购入充电器的小伙伴们有所
2021-06-01 09:31:42
除了L4WUDU与吴亦凡已经多次共事,成为了明面上的厂牌成员,吴亦凡还曾带领20XXCLUB全队参加2020年的一场音乐节,这也是20XXCLUB首次全员合照,王嗣尧Turbo、陈彦希Regi、<em>Mac</em> Ova Seas、林渝植等人全部出场。然而让
2021-06-01 09:31:34
目前应用IPFS的机构:1 谷歌<em>浏览器</em>支持IPFS分布式协议 2 万维网 (历史档案博物馆)数据库 3 火狐<em>浏览器</em>支持 IPFS分布式协议 4 EOS 等数字货币数据存储 5 美国国会图书馆,历史资料永久保存在 IPFS 6 加
2021-06-01 09:31:24
开拓者的车机是兼容苹果和<em>安卓</em>,虽然我不怎么用,但确实兼顾了我家人的很多需求:副驾的门板还配有解锁开关,有的时候老婆开车,下车的时候偶尔会忘记解锁,我在副驾驶可以自己开门:第二排设计很好,不仅配置了一个很大的
2021-06-01 09:30:48
不仅是<em>安卓</em>手机,苹果手机的降价力度也是前所未有了,iPhone12也“跳水价”了,发布价是6799元,如今已经跌至5308元,降价幅度超过1400元,最新定价确认了。iPhone12是苹果首款5G手机,同时也是全球首款5nm芯片的智能机,它
2021-06-01 09:30:45