r软件基础知识与实战

r软件基础知识与实战

ID:34725591

大小:239.68 KB

页数:54页

时间:2019-03-10

r软件基础知识与实战_第1页
r软件基础知识与实战_第2页
r软件基础知识与实战_第3页
r软件基础知识与实战_第4页
r软件基础知识与实战_第5页
资源描述:

《r软件基础知识与实战》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、R软件基础知识与实战第一课:基本知识第二课:基本运算第三课:画图第四课:数据整理和数据分析第五课:统计分析第六课:分布的产生第七课:求导和极值的计算第八课:Bootstrap方法第九课:MCMC算法第一课基本知识一.R的历史与特点Object-oriented语言二.R系统介绍安装镜像Installingpackageslibrary(survival)#加载程序包library(help=survival)#显示程序包survival里的内容help(mean)#查看关于函数mean的帮助search()#给出系统里已加载的程序包searchpaths()#给出系统

2、里已加载的程序包的路径Commandsareseparatedeitherbysemicolonoranewline三.Dataobjects#Thereare7basictypesofdataobjects:#Vector,Matrix,Array,List,Factor,Timeseries,Dataframe#creatingvectors#vectortype:character,numeric,integer,logical,complexmy1<-c(1.2,2.3,3.5,4.6,5.7)my2<-c("Monday","Tuesday","Wednes

3、day","Thursday","Friday","Saturday","Sunday")rep(NA,5)rep(c(T,T,F),2)rep(c("yes","no"),c(4,2))1:51.2:41:-1seq(-pi,pi,.5)seq(-pi,pi,length=10)seq(1,by=.05,length=10)a1=vector("logical",3)a2=numeric(4);a3=complex(5);a4=character(6)#what’sthedifferencebetween?mat1<-rep(1:4,rep(3,4))mat2<-r

4、ep(1:4,3)scan()scan(what="")#扫描字符型变量numbered.letters<-lettersnames(numbered.letters)<-paste(“obs”,1:26,sep=””)#generatingmatrixmat1<-matrix(1:12,ncol=3,byrow=T)dimnames(mat1)=list(c("row1","row2","row3","row4"),c("col1","col2","col3"))mat2<-matrix(1:12,ncol=4,dimnames=list(NULL,paste("c

5、ol",1:4)))mat<-rep(1:4,rep(3,4))dim(mat)<-c(3,4)dimnames(mat)<-list(paste("row",letters[1:3]),paste("col",LETTERS[1:4]))rbind(c(200688,24,33),c(201083,27,115))dim(mat)#arrayarray(c(1:8,11:18,111:118),dim=c(2,4,3))#listattributes(iris)grp<-c(rep(1,11),rep(2,10))thw<-c(450,760,325,495,285

6、,450,460,375,310,245,350,340,300,310,270,300,360,405,290)heart.list<-list(group=grp,thw=thw,descrip="heartdata")names(heart.list)names(heart.list)<-c("group","totalheartweight","descrip")#factorsclasslist<-c("male","female","male","male","male","female","female","male","female")classlis

7、t=factor(classlist)factor(c("Hi","Lo","Med","Hi","Hi","Lo"),levels=c("Lo","Hi"),labels=c("LowDose","HighDose"))cut(state.x77[,"Murder"],breaks=c(0,8,16))cut(state.x77[,"Murder"],breaks=2)cut(state.x77[,"Murder"],c(0,8,16),labels=c("Low","High"))#dataframescars=read.table("D:/93

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。