R语言介绍

本文由用户“q十年q究”分享发布 更新时间:2020-03-26 13:36:29 举报文档

以下为《R语言介绍》的无排版文字预览,完整格式请下载

下载前请仔细阅读文字预览以及下方图片预览。图片预览是什么样的,下载的文档就是什么样的。

R-语言/软件R免费

R 资源公开(不是黑盒子,也不是吝啬鬼)

R可以在UNIX, Windows和Macintosh运行.

R 有优秀的内在帮助系统.

R有优秀的画图功能

学生能够轻松地转到商业支持的 S-Plus程序(如果需要使用商业软件)

R语言有一个强大的,容易学习的语法,有许多内在的统计函数.通过用户自编程序, R语言很容易延伸和扩大. 它就是这样成长的.

R 是计算机编程语言. 类似于UNIX语言,C语言, Pascal,Gauss 语言等.

对于熟练的编程者, 它将觉得该语言比其他语言更熟悉.

而对计算机初学者, 学习R语言使得学习下一步的其他编程不那么困难.R的缺点不如S-Plus在编辑输出的画图那样好

没有商业支持 (但有网上支持)

需要编程, 不傻瓜.R的历史S语言在1980年代后期在AT&T实验室开发.

R 项目由Auckland 大学统计系的Robert Gentleman和Ross Ihaka于1995年开始的.

它很快得到广泛用户的欢迎. 目前它是由R核心发展团队维持;它是一个由志愿者组成的工作努力的国际团队.点击CRAN得到一批镜像网站下载R(http://doc.001pp.com/)点击镜像网站比如 China---- tsinghua.edu.cn选择这个,下载安装文件选择这个,下载软件包R里面有什么? Packages(每个都有大量数据和可以读写修改的函数/程序)一些常用Packagesbase The R Base Package

boot Bootstrap R (S-Plus) Functions (Canty)

class Functions for Classification

cluster Cluster Analysis Extended Rousseeuw et al.

concord Concordance and reliability

datasets The R Datasets Package

exactRankTests Exact Distributions for Rank and Permutation Tests

foreign Read Data Stored by Minitab, S, SAS, SPSS, Stata, Systat, dBase, ...

graphics The R Graphics Package

grDevices The R Graphics Devices and Support for Colours and Fonts

grid The Grid Graphics Package

KernSmooth Functions for kernel smoothing for Wand & Jones (1995)

lattice Lattice Graphics Interface

tools Tools for Package Development

utils The R Utils Package一些常用Packages (继续)MASSMain Package of Venables and Ripley's MASS

methodsFormal Methods and Classes

mgcvGAMs with GCV smoothness estimation and GAMMs by REML/PQL

multtestResampling-based multiple hypothesis testing

nlmeLinear and nonlinear mixed effects models

nnetFeed-forward Neural Networks and Multinomial Log-Linear Models

nortestTests for Normality

outliersTests for outliers

plsPartial Least Squares Regression (PLSR) and Principal Component Regression (PCR)

pls.pcrPLS and PCR functions

rpartRecursive Partitioning

SAGxStatistical Analysis of the GeneChip

smaStatistical Microarray Analysis

spatialFunctions for Kriging and Point Pattern Analysis

splinesRegression Spline Functions and Classes

statsThe R Stats Package

stats4Statistical Functions using S4 Classes

survivalSurvival analysis, including penalised likelihood.

tcltkTcl/Tk Interface

toolsTools for Package Development

utilsThe R Utils Package所有这些Packages都是在base 和 stats package上添加的 Base, stats包含所有固有的应用和数据

而其他的packages包含各统计学家自己发展的方法和数据。

希望你是下一个加盟这些packages的作者之一。?Task Views一定要使用帮助文件!

怎么使用帮助文件!

赋值和运算 z = rnorm(***,4,0.1)

median(z)

赋值: “=”可以用“w

简单数学运算有: +,-,*,/, ^,%*%,%%(mod) %/%(整数除法)等等

常用的数学函数有:abs , sign , log , log2, log10 , logb, expm1, log1p(x), sqrt , exp , sin , cos , tan , acos , asin, atan , cosh , sinh, tanh

还有 round, floor, ceiling

gamma , lgamma, digamma and trigamma.

sum, prod, cumsum, cumprod

max, min, cummax, cummin, pmax, pmin, range

mean, length, var, duplicated, unique

union, intersect, setdiff

>, >=, x

[,1] [,2] [,3] [,4] [,5]

[1,] 0.*** 0.*** 0.*** 0.*** 0.***

[2,] 0.*** 0.*** 0.*** 0.*** 0.***

[3,] 0.*** 0.*** 0.*** 0.*** 0.***

[4,] 0.*** 0.*** 0.*** 0.*** 0.***

> x=matrix(1:20,4,5); x

[,1] [,2] [,3] [,4] [,5]

[1,] 1 5 9 13 17

[2,] 2 6 10 14 18

[3,] 3 7 11 15 19

[4,] 4 8 12 16 20

> x=matrix(1:20,4,5,byrow=T);x

[,1] [,2] [,3] [,4] [,5]

[1,] 1 2 3 4 5

[2,] 6 7 8 9 10

[3,] 11 12 13 14 15

[4,] 16 17 18 19 20一些简单函数max,min,length,mean,median, fivenum,quantile,unique,sd,var,range,rep,diff,sort,order,sum,cumsum,prod,cumprod,rev,print,sample,seq,exp,pi矩阵的行和列(子集)nrow(x); ncol(x);dim(x)#行列数目

x=matrix(rnorm(24),4,6)

x[c(2,1),]#第2和第1行

x[,c(1,3)] #第1和第3列

x[2,1] #第[2,1]元素

x[x[,1]>0,1] #第1列大于0的元素

sum(x[,1]>0) #第1列大于0的元素的个数

sum(x[,1]0&x[,3]0|x[,1]0);(1:10)[x>0]

x=sample(1:7,5,rep=T);unique(x)矩阵的转置和逆矩阵x=matrix(runif(9),3,3);x

[,1] [,2] [,3]

[1,] 0.*** 0.*** 0.***

[2,] 0.*** 0.*** 0.***

[3,] 0.*** 0.*** 0.***

t(x) # 转置矩阵

[,1] [,2] [,3]

[1,] 0.*** 0.*** 0.***

[2,] 0.*** 0.*** 0.***

[3,] 0.*** 0.*** 0.***

solve(x) #逆矩阵, solve(a,b)可以解ax=b方程

[,1] [,2] [,3]

[1,] -12.313293 15.125819 9.082300

[2,] -8.459725 3.627898 8.989864

[3,] 23.563034 -18.363808 -20.037986警告:计算机中的0是什么?x%*%solve(x)

[,1] [,2] [,3]

[1,] 1.000000e+00 -9.454243e-17 -3.911801e-16

[2,] 5.494737e-16 1.000000e+00 3.248270e-16

[3,] -3.018419e-16 1.804980e-15 1.000000e+00

要用线性代数的知识来判断诸如有多少非零特征根等问题.假定v是特征值组成的向量,不能用诸如sum(v!=0) 等方法来判断非零特征根的数目!Matrix & Array x=array(runif(20),c(4,5)); x

[,1] [,2] [,3] [,4] [,5]

[1,] 0.*** 0.*** 0.***7 0.*** 0.***

[2,] 0.*** 0.*** 0.***4 0.*** 0.***

[3,] 0.*** 0.*** 0.***4 0.*** 0.***

[4,] 0.*** 0.*** 0.***5 0.*** 0.***

is.matrix(x)

[1] TRUE

x[1,2]

x[1,]

x[,2]

dim(x)#得到维数(4,5)Array x=array(runif(24),c(4,3,2))

is.matrix(x) #可由dim(x)得到维数(4,3,2)

[1] FALSE

x

, , 1

[,1] [,2] [,3]

[1,] 0.*** 0.*** 0.***2

[2,] 0.*** 0.*** 0.***7

[3,] 0.*** 0.*** 0.***2

[4,] 0.*** 0.*** 0.***8

, , 2

[,1] [,2] [,3]

[1,] 0.*** 0.*** 0.***

[2,] 0.*** 0.*** 0.***

[3,] 0.*** 0.*** 0.***

[4,] 0.*** 0.*** 0.***Array的子集 > x=array(1:24,c(4,3,2))

x[c(1,3),,]

, , 1

[,1] [,2] [,3]

[1,] 1 5 9

[2,] 3 7 11

, , 2

[,1] [,2] [,3 内容过长,仅展示头部和尾部部分文字预览,全文请查看图片预览。 - mu)^2, 2 * sigma^2)})), cex = 1.2)

注:下标用X[i]example(plotmath)略……NULL 空 symbol 一个变量名字 pairlist 成对列表对象 closure 一个函数 environment 一个环境 promise 一个用于实现悠闲赋值的对象 language 一个 R 语言构建 special 一个不可针对参数求值的内置函数 builtin 一个可针对参数求值的内置函数 logical 含逻辑值的向量 integer 含整数值的向量 double 含实数值的向量 complex 含复数值的向量 character 含字符值的向量 ... 特定变量长度参数 *** any 一个可以匹配任何类型的特殊类型 *** expression 一个表达式对象 list 一个列表 externalptr 一个外表指针对象 weakref 一个弱引用对象(a weak reference object) raw 一个字节元素向量 [文章尾部最后500字内容到此结束,中间部分内容请查看底下的图片预览]请点击下方选择您需要的文档下载。

  1. Atlantic Herring
  2. 2019——2020学年第一学期八年级英语期末测试题(WORD无听力,有答案和部分解析)
  3. 教学设计课题NewZealand
  4. California-Reading课件
  5. WHO新冠疫苗技术线路(英文)
  6. 英语作文模板万能句型
  7. 英语演讲印度喜剧电影《三傻大闹宝莱坞》
  8. 审稿意见模板
  9. 18类英语满分范文汇总
  10. 【热点英语试题】新冠病毒肺炎的英语原创试题最全汇总(1)
  11. 英文presentation
  12. Batch Job - AAAU - AU001b - BO Accepted STD Pick R
  13. Making the news作业
  14. art%3A10.1007%2Fs1***-8
  15. R语言介绍
  16. phaserjsgamedesignworkbook-sample
  17. Unit3Lifeinthefuture
  18. Learningaims
  19. Unit1Topic3Howold
  20. 四级词汇词根 联想记忆法乱序版_绿皮书(1)

以上为《R语言介绍》的无排版文字预览,完整格式请下载

下载前请仔细阅读上面文字预览以及下方图片预览。图片预览是什么样的,下载的文档就是什么样的。

图片预览