开发者学堂课程【大数据之 R 语言速成与实战:R 的常用命令】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/363/detail/4323
R 的常用命令
内容介绍
一、R 的常用命令
一、R 的常用命令
①
> ls()
character (0)
> data<-c(1,2,4,5)
> strings <-"I like R"
>Is()
[1] "data" "strings"
> rm(data)
>ls()
[1]
"strings"
>a<-1
>A<-2
> ls()
[1] "a" "A" "strings"
>V<-c(4,7,23,56,32 )
> length (v)
[1]
5
> mode (v)
[1]
"numeric"
> c<- C(1,2,3,"r")
> mode(c)
[1]
"character"
>c
[1]
"1" "2" "3" "r"
>c[2] - "test"
>c
[1]"1" "test" "3" "r"
>x<- C(4,8,9,15,24)
>y<- sqrt (x)
>y
[1]
2.000000 2.828427 3.000000 3.872983 4.898979
>z<-x+y
>z
[1]
6.00000 10.82843 12.00000 18.87298 28.89898
>X<- c(1,1,1,1,1,1)
y<- c(2,2,2)
z<-x+y
[1]
3 3 33 3 3
[2]
> x<- 1:1000
>length(x)
[1]
1000
> x
②
>X <- seq(1,10,2)
> X
[1]
1 3 5 7 9
> X <- rep(5,10)
> X
[1]
5 5 5 5 5 5 5 5 5 5
[2]
> rep(1:3,3)
[1]
1 2 3 1 2 3 1 2 3
> rnorm (10)
[1]1.176555391 0.117578673 -0.001891701 -0.621917268 -0.301895078 -0,201588205 2.903450724 0.511170206
[9]
0.460424768 -1.275409861
> rnorm(6,mean=6,sd=2)
[1]
2.857149 5.234534 6.819100 5.283175 2.946540 7.915748
> x<- C(0,-3,4,-1,45,98,-12)
>x[x>0]
[1]
4 45 98
> x[x<=-2 | X>5]
[1]
-3 45 98 -12
>x [-5]
[1]
0 -3 4 -198 -12
> x[-(1:3)]
[1]
-1 45 98 -12
>