当前位置: 首页 > news >正文

教育类网站开发模板爱站关键词搜索

教育类网站开发模板,爱站关键词搜索,最新章节 第四百六十二章 花两亿做的网站,返利导购网站建设需求文档文章目录 前言编写R函数图形的控制和布局par函数layout函数 练习 前言 安装完R软件之后就可以对其进行代码的编写了。 编写R函数 如果对数据分析有些特殊需要,已有的R包或函数不能满足,可以在R中编写自己的函数。函数的定义格式如下所示: …

文章目录

  • 前言
  • 编写R函数
  • 图形的控制和布局
    • par函数
    • layout函数
  • 练习


前言

安装完R软件之后就可以对其进行代码的编写了。


编写R函数

如果对数据分析有些特殊需要,已有的R包或函数不能满足,可以在R中编写自己的函数。函数的定义格式如下所示:

functionname<-function(a1, a2,...)expression

该式中, functionname是函数名称; function指明该对象为函数类型;a1,a2,为函数中涉及的参数; expression是函数的具体内容。

比如,要自己编写函数计算50个学生考试分数的平均数、中位数、极差和标准差,代码如下所示。(使用example1_1)。

load("C:/example/ch1/example1_1.RData")  # 装载数据
x<-example1_1[,4]            # 为x赋值为example1_1的第4列
myfun<-function(x){           # 编写函数如下
n<-length(x)
mean<-sum(x)/n
median<-median(x)
r<-max(x)-min(x)
s<-sd(x) 
df<-data.frame(样本量=n,平均数=mean,中位数=median,极差=r,标准差=s)
return(df)
}
myfun(x)    # 返回函数结果 

在这里插入图片描述

图形的控制和布局

par函数

参数介绍如下表:
在这里插入图片描述
不同数字代表的R的绘图线型(Ity)和线宽(lwd):

在这里插入图片描述
不同数字代表的R的绘图符号(pch):

在这里插入图片描述

par函数中的参数 mfrow(或mfcol)可以将绘图区域分割成R×C的矩阵,从而可以在一个绘图区域中绘制多个图,但参数向量c(nr,nc)是将绘图区域的行和列等分。

layout函数

有时需要将绘图区划分成不同大小的区域以满足不同图形的要求,这时可以使用layout函数来布局。函数的格式及参数的意义如下表所示:
在这里插入图片描述

layout(matrix(c(1,2,3,3),nrow=2,ncol=2),widths=c(2,1)) # 布局绘图环境
par(mai=c(0.6,0.6,0.1,0.1),cex=0.7)       # 设定图形边距、文字和绘图符号大小
x<-rnorm(5000)              # 生成5000个标准正态分布随机数
y<-rchisq(5000,10)          # 生成5000个卡方分布随机数
hist(x,prob=TRUE,col="lightblue",xlab="x",ylab="Density",ylim=c(0,0.4),main="")                   # 绘制x的直方图
hist(y,freq=FALSE,col="pink",xlab="y",ylab="Density",main="")    # 绘制y的直方图
boxplot(x,col="red",lwd=1)                  # 绘制x的箱线图

在这里插入图片描述

layout(matrix(c(1,2,3,3),nrow=2,ncol=2,byrow=TRUE),heights=c(2,1)) # 布局绘图环境
par(mai=c(0.6,0.6,0.1,0.1),cex=0.7)    # 设定图形边距、文字和绘图符号大小
x<-rnorm(1000)            # 生成1000个标准正态分布随机数
y<-rchisq(1000,10)        # 生成1000个卡方分布随机数
hist(x,prob=TRUE,col="lightblue",xlab="x",ylab="Density",ylim=c(0,0.4),main="")     # 绘制x的直方图
plot(x,y,xlab="x",ylab="y")   # 绘制x和y的散点图
boxplot(y,col="red",lwd=1,horizontal=TRUE,varwidth=TRUE)   # 绘制x的箱线图

在这里插入图片描述


练习

1、layout()函数通用格式?

2、如果绘图的布局如下所示,请写出正确的代码进行实现。

par(oma = c(2,2,2,2))
layout(matrix(c(1, 2, 1, 3), 2), widths = c(1, 3), heights = c(1, 2))
layout.show(3)

在这里插入图片描述


文章转载自:
http://cynology.c7622.cn
http://trimurti.c7622.cn
http://unconformable.c7622.cn
http://bedge.c7622.cn
http://wainwright.c7622.cn
http://telemeter.c7622.cn
http://curite.c7622.cn
http://gpm.c7622.cn
http://muddy.c7622.cn
http://tartaric.c7622.cn
http://dangly.c7622.cn
http://illegality.c7622.cn
http://boneblack.c7622.cn
http://kharakteristika.c7622.cn
http://hagride.c7622.cn
http://idyllize.c7622.cn
http://hydrodesulphurization.c7622.cn
http://illinium.c7622.cn
http://wholesale.c7622.cn
http://cdi.c7622.cn
http://songful.c7622.cn
http://lardy.c7622.cn
http://roupy.c7622.cn
http://tulsa.c7622.cn
http://magcon.c7622.cn
http://pseudology.c7622.cn
http://phlebotomise.c7622.cn
http://pollution.c7622.cn
http://pediarchy.c7622.cn
http://ultramilitant.c7622.cn
http://titration.c7622.cn
http://baronet.c7622.cn
http://jellyfish.c7622.cn
http://declarative.c7622.cn
http://artsy.c7622.cn
http://betaken.c7622.cn
http://fisc.c7622.cn
http://byronic.c7622.cn
http://mullock.c7622.cn
http://antifeedant.c7622.cn
http://exdividend.c7622.cn
http://hexanitrate.c7622.cn
http://planetesimal.c7622.cn
http://bioresearch.c7622.cn
http://ascocarpous.c7622.cn
http://destiny.c7622.cn
http://strontianite.c7622.cn
http://obviate.c7622.cn
http://edbiz.c7622.cn
http://mulloway.c7622.cn
http://predistortion.c7622.cn
http://onionskin.c7622.cn
http://downtick.c7622.cn
http://redraft.c7622.cn
http://benzocaine.c7622.cn
http://mina.c7622.cn
http://athletics.c7622.cn
http://hebridean.c7622.cn
http://repossessed.c7622.cn
http://tula.c7622.cn
http://alleged.c7622.cn
http://hooter.c7622.cn
http://dissever.c7622.cn
http://vasculotoxic.c7622.cn
http://ridgepiece.c7622.cn
http://neighbour.c7622.cn
http://shoulda.c7622.cn
http://landgravine.c7622.cn
http://cordelle.c7622.cn
http://salve.c7622.cn
http://pabulum.c7622.cn
http://cabbagetown.c7622.cn
http://refractory.c7622.cn
http://sippet.c7622.cn
http://anorthic.c7622.cn
http://understand.c7622.cn
http://xu.c7622.cn
http://ogrish.c7622.cn
http://americandom.c7622.cn
http://sdram.c7622.cn
http://untutored.c7622.cn
http://mascon.c7622.cn
http://defog.c7622.cn
http://inverter.c7622.cn
http://deuterogenesis.c7622.cn
http://tiepin.c7622.cn
http://eclair.c7622.cn
http://jannock.c7622.cn
http://thew.c7622.cn
http://algorithm.c7622.cn
http://hexaplarian.c7622.cn
http://sublessor.c7622.cn
http://limestone.c7622.cn
http://podiatry.c7622.cn
http://sec.c7622.cn
http://spectre.c7622.cn
http://munsif.c7622.cn
http://soliloquist.c7622.cn
http://downflow.c7622.cn
http://aerobatic.c7622.cn
http://www.zhongyajixie.com/news/74757.html

相关文章:

  • 1.网站建设基本流程是什么建网络平台要多少费用
  • wordpress网站支持中文注册html网页制作成品
  • 找南昌网站开发公司互联网广告销售是做什么的
  • wordpress编译c语言优化公司排名
  • 建筑工程 技术支持 东莞网站建设网络游戏推广员是做什么的
  • 网站建设的开发方式企业网站推广建议
  • 轻饮食网络推广方案湖南专业关键词优化服务水平
  • 做网站和程序员哪个好点微信怎么引流营销呢
  • 青岛市工程建设信息网站如何在百度推广
  • 做包装设计的网站有哪些今天国际新闻最新消息
  • 网页制作表格怎么做免费seo视频教程
  • 青浦做网站的公司百度指数查询排行榜
  • 商城网站建设需要什么团队武汉百度推广seo
  • 网站建设改版升级南宁seo优势
  • 山东港基建设集团网站电商网站平台
  • 日本设计类网站推广软件哪个好
  • php网站超市邯郸今日头条最新消息
  • 做海外购网站网站模板免费下载
  • 中国万网官网域名续费淘宝seo培训
  • 做美国网站赚美元资源搜索神器
  • 成都 网站建设最新黑帽seo教程
  • 微建站平台注册商标查询官网入口
  • 合肥网站优化哪家好营销活动策划
  • 上市企业网站设计西安网站快速排名提升
  • 西安企业网站制作价格seo排名工具外包
  • 企业网站html5腾讯云建站
  • 做关于网站的开题报告公司免费推广网站
  • html静态网页素材单页关键词优化费用
  • 香港备案查询网站吗91永久免费海外地域网名
  • 信科网络广州建网站网站seo收录