R语言实验报告.docx

R语言实验报告.docx

ID:60809710

大小:92.26 KB

页数:8页

时间:2020-12-20

R语言实验报告.docx_第1页
R语言实验报告.docx_第2页
R语言实验报告.docx_第3页
R语言实验报告.docx_第4页
R语言实验报告.docx_第5页
资源描述:

《R语言实验报告.docx》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、实验目的根据教科书上数据,作图,以及实现关于分布的假设检验,要求选择的数据除了服从正态分布外,还应选择一些其它类型的数据实验内容(一)根据教科书上数据,作图基本图形:直方图、条形图、点图和箱线图(参考书本例题mtcars)、饼图和扇形图(书本例题:国别数据)attach(mtcars)opar<-par(no.readonly=TRUE)par(mfrow=c(3,1))hist(wt)hist(mpg)hist(disp)par(opar)detach(mtcars)attach(mtcars)layout(matrix(c

2、(1,1,2,3),2,2,byrow=TRUE))hist(wt)hist(mpg)hist(disp)detach(mtcars)attach(mtcars)plot(wt,mpg)abline(lm(mpg~wt))title("RegressionofMPGonWeight")detach(mtcars)pdf("mygraph.pdf")attach(mtcars)plot(wt,mpg)abline(lm(mpg~wt))title("RegressionofMPGonWeight")detach(mtcars)a

3、ttach(mtcars)opar<-par(no.readonly=TRUE)par(mfrow=c(2,2))plot(wt,mpg,main="Scatterplotofwtvs.mpg")plot(wt,disp,main="Scatterplotofwtvs.disp")hist(wt,main="Histogramofwt")boxplot(wt,main="Boxplotofwt")par(opar)detach(mtcars)饼图和扇形图(书本例题:国别数据)par(mfrow=c(2,2))slices<-c

4、(10,12,4,16,8)lbls<-c("US","UK","Australia","Germany","France")pie(slices,labels=lbls,main="SimplePieChart")pct<-round(slices/sum(slices)*100)lbls<-paste(lbls,pct)lbls<-paste(lbls,"%",sep="")pie(slices,labels=lbls,col=rainbow(length(lbls)),main="PieChartwithPercenta

5、ges")library(plotrix)slices<-c(10,12,4,16,8)lbls<-c("US","UK","Australia","Germany","France")fan.plot(slices,labels=lbls,main="FanPlot")核密度图d<-density(mtcars$mpg)#returnsthedensitydataplot(d)#plotstheresultsd<-density(mtcars$mpg)plot(d,main="KernelDensityofMilesPerG

6、allon")polygon(d,col="red",border="blue")rug(mtcars$mpg,col="brown")(二)关于分布的假设检验(来自书本数据男女老少体重)>fit<-lm(weight~height,data=women)>summary(fit)Call:lm(formula=weight~height,data=women)Residuals:Min1QMedian3QMax-1.7333-1.1333-0.38330.74173.1167Coefficients:EstimateStd.

7、ErrortvaluePr(>

8、t

9、)(Intercept)-87.516675.93694-14.741.71e-09***height3.450000.0911437.851.09e-14***---Signif.codes:0‘***’0.001‘**’0.01‘*’0.05‘.’0.1‘’1Residualstandarderror:1.525on13degreesoffreedomMultipleR-squared:0.991,AdjustedR-squared:0.9903F-statistic:1433on1an

10、d13DF,p-value:1.091e-14>women$weight[1]115117120123126129132135139142146150154159164>fitted(fit)12345678112.5833116.0333119.4833122.933312

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

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

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