R 语言--初识

241 阅读1分钟

1.1 What is R?

Introduction to R:

R is a language and environment for statistical computing and graphics.
R是统计计算和图形的语言和环境。

1.2 Download and Install R

下载网站:www.r-project.org

进入官网后如下图,点击CRAN:

选择中国内的镜像:
此处安装Windows版:
base版本即可:
下载:
双击exe文件安装:
最简单的方法直接默认安装。

1.3 R 初运行

初始运行界面:

code example:

> 2+2
[1] 4
> log(2)
[1] 0.6931472
> log10(2)
[1] 0.30103
> 2+2w
错误: unexpected symbol in "2+2w"

简单函数介绍:

  • ? 访问帮助文件 ?boxplot
  • # 添加注释 #Add your command here
  • log() 自然对数 log(2)
  • log10() 以10为底的对数 log10(2)
  • setwd() 设置工作目录 setwd(C:/AnyDirectory)
  • q() 退出 q()