标签:
1、典型的数据分析过程可以总结为一下图形:
注意,在模型建立和验证的过程中,可能需要重新进行数据清理和模型建立。 2、R语言一般用 <- 作为赋值运算符,一般不用 = ,原因待考证。用->也可以。 3、 age <- c(1,3,5,2,11,9,3,9,12,3)
weight <- c(4.4,5.3,7.2,5.2,8.5,7.3,6.0,10.4,10.2,6.1)
mean(weight)
sd(weight)
cor(age,weight)
plot(age,weight)
上面这一段代码是基本的展示,其中
sd:求标准差函数。
cor:求相关(线性)系数,相关阵或者协方差阵。
下面是涉及到的几个函数:
demo:示例函数,后面加具体函数会有示例展示,不加参数显示demo列表。特别的,用demo可以查看不少漂亮的图例,demo下面的参数有很多,有着不同的功能,下面贴一下执行demo()之后得到的结果。
Demos in package ‘base’: error.catching More examples on catching and handling errors is.things Explore some properties of R objects and is.FOO() functions. Not for newbies! recursion Using recursion for adaptive integration scoping An illustration of lexical scoping. Demos in package ‘graphics’: Hershey Tables of the characters in the Hershey vector fonts Japanese Tables of the Japanese characters in the Hershey vector fonts graphics A show of some of R‘s graphics capabilities image The image-like graphics builtins of R persp Extended persp() examples plotmath Examples of the use of mathematics annotation Demos in package ‘grDevices’: colors A show of R‘s predefined colors() hclColors Exploration of hcl() space Demos in package ‘stats’: glm.vr Some glm() examples from V&R with several predictors lm.glm Some linear and generalized linear modelling examples from `An Introduction to Statistical Modelling‘ by Annette Dobson nlm Nonlinear least-squares using nlm() smooth `Visualize‘ steps in Tukey‘s smoothers Use ‘demo(package = .packages(all.available = TRUE))’ to list the demos in all *available* packages.
其中,graphics是一个包,用来画图形。试一试这些参数看看都是什么效果:
Hershey:一种字体,赫尔希研发的矢量字体,用来渲染文本用的;
其他的看说明能猜到,有一些:
persp:貌似用来画三维图形;
plotmath:数学公式的对应的函数名称,可能会很有用以后;
is.things:is.XXX的各种函数列表;
recursion:跟递归有关系……;
colors:R内置的颜色,很多彩;
hclColors:颜色扩充,更多姿多彩了!。
4、关于R中的帮助,用的最多的就是?+函数名了,没想到还有这些可以用:
感觉用?和??最方便,不过没怎么试过example,下回试试;另外,貌似apropos可能适合乱找一些相关函数;data()挺好,可以看现在那些数据集可以用,比如用过的iris就可以看到到;vignette函数可以查看安装的包里面的vignette文档,先用vignette()查看文档名,再用vignette(文档名)就可以直接打开文档。
5、R工作空间管理函数:
其中,删除所有变量的语句为:rm(list = ls(all = TRUE)).用options()命令可以设置一些环境变量,比如options(digits=10),这个命令,可以把R的整数表示能力设为10位(来自:http://blog.csdn.net/aldenphy/article/details/9405305)。R语言中的正斜杠‘/’表示目录,比如“E:/R”,而反斜杠‘\’表示转义字符。setwd函数不会创建不存在的文件夹,可以用dir.create函数创建目录。以后每次开始的时候先设置一个目录是极好的!
sink函数第一次听说:
标签:
原文地址:http://www.cnblogs.com/batteryhp/p/4693116.html