R 绘制箱线图的绘制方法(plot、boxplot、qplot)

 时间:2024-10-13 03:08:47

1、#读取数据集以ggplot2中的diamonds数据集为例。library(ggplot2)sample1=diamonds[sample(nrow(diamonds),100),]attach(sample1)#当x为分类变量时,plot函数可自动绘制出箱线图plot(cut, price)

R 绘制箱线图的绘制方法(plot、boxplot、qplot)

2、在boxplot函数中,可以使用公式来实现。boxplot(price ~ cut巳呀屋饔, data = sample1,col=rainbow(7))也可以用ggplot2中的函数实现,下面怎剑词阶两行代码运行的结果相同。qplot(cut, price, data=sample1, geom="boxplot")ggplot(sample1, aes(x=cut, y=price)) + geom_boxplot()

R 绘制箱线图的绘制方法(plot、boxplot、qplot)
R 绘制箱线图的绘制方法(plot、boxplot、qplot)

3、# 两个x变量同时作用boxplot(price ~ cut+color巳呀屋饔, data = sample1,col=rainbow(7))ggplot2的实现方法:qplot(intera艘早祓胂ction(cut, color), price, data=sample1, geom="boxplot")ggplot(sample1, aes(x=interaction(cut, color), y=price)) + geom_boxplot()

R 绘制箱线图的绘制方法(plot、boxplot、qplot)
  • 怎样把慕课的ppt导出来
  • 学习通如何下载课件PPT?
  • SPSS之数据预处理
  • 知网怎么精确检索某种期刊的文献
  • pubmed怎么下载文献
  • 热门搜索
    生物手抄报内容 关于爱鸟护鸟的手抄报 名胜古迹手抄报 孝行雅行我先行手抄报 我的绿色环保梦手抄报 爱国的手抄报内容 法制小报手抄报 初中英语手抄报版面 平安校园手抄报资料 感恩的手抄报内容