版权声明:All rights reserved by LK12, reprint please explain the source https://blog.csdn.net/qq_40527086/article/details/82987332
R语言学习笔记三 常用函数
在R中,可以用help(‘functionName’)或?functionName查看函数帮助文件
使用args(‘functionName’)查看函数参数,例如对抽样函数的使用
help("sample")
会出现帮助文件。
数学函数和运算符
函数 | 用途 |
---|---|
sqrt() | 平方根 |
log() | 对数 |
exp() | 指数 |
sin()/cos()/tan() | 三角函数 |
asin()/acos()/atan() | 反三角函数 |
abs() | 求绝对值 |
统计函数汇总
函数 | 用途 | 函数 | 用途 |
---|---|---|---|
mean | 平均数 | min | 最小值 |
median | 中位数 | max | 最大值 |
sd | 标准差 | var | 方差 |
range | 值域 | length | 向量长度 |
mad | 绝对中位差 | sum | 总和 |
注意有缺失值时会取中位数等可能会返回缺失值。
模拟和统计分布函数
分布名称 | 代码 | 分布名称 | 代码 |
---|---|---|---|
正态分布 | norm | 泊松分布 | pois |
二项分布 | binom | 指数分布 | exp |
均匀分布 | unif | 韦伯分布 | weibull |
贝塔分布 | beta | 伽马分布 | gamma |
F分布 | f | 卡方分布 | chisq |
分布函数
首字母 | 描述 | 第一个参数 | 示例 |
---|---|---|---|
d | 某分位数点密度 | x(分位数) | dnorm(1.64) |
p | 到分位数某点累计密度 | q (分位数) | pnorm(1.64) |
q | 某累计概率对应的分位数 | p(概率) | qnorm(0.9) |
r | 随机抽样 | n(样本个数) | rnorm(10) |