sub("dog","cat",a) [1] "The cat ate my homework“ > a = (1+1==3) > a [1] FALSE numeric character string logical"> sub("dog","cat",a) [1] "The cat ate my homework“ > a = (1+1==3) > a [1] FALSE numeric character string logical">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

R. > log2(32) [1] 5 > sqrt(2) [1] 1.414214 > seq(0, 5, length=6) [1] 0 1 2 3 4 5 > plot(sin(seq(0, 2*pi, length=100)))

Similar presentations


Presentation on theme: "R. > log2(32) [1] 5 > sqrt(2) [1] 1.414214 > seq(0, 5, length=6) [1] 0 1 2 3 4 5 > plot(sin(seq(0, 2*pi, length=100)))"— Presentation transcript:

1 R

2 > log2(32) [1] 5 > sqrt(2) [1] 1.414214 > seq(0, 5, length=6) [1] 0 1 2 3 4 5 > plot(sin(seq(0, 2*pi, length=100)))

3 > a = 49 > sqrt(a) [1] 7 > a = "The dog ate my homework" > sub("dog","cat",a) [1] "The cat ate my homework“ > a = (1+1==3) > a [1] FALSE numeric character string logical

4 vector: an ordered collection of data of the same type > a = c(1,2,3) > a*2 [1] 2 4 6 > a = c(7,5,1) > a[2] [1] 5 list: an ordered collection of data of arbitrary types. > doe = list(name="john",age=28,married=F) > doe$name [1] "john“ > doe$age [1] 28

5 x<-rnorm(n=32,mean=80,sd=10) hist(x)

6 x<-matrix(1:6,2,3) # 製造一個 2*3 的矩陣 x ,其數值 為 1 到 6 x[2,3]==6 # x 矩陣第 2row 第 3column 的值是否等於 6 x[x<=3] # 列出 x 矩陣內小於或等於 3 的數值 x[x!=6] # 列出 x 矩陣內不等於 6 的數值 x[x<=3 & x!=2] # 列出 x 矩陣內小於或等於 3 且不等於 2 的值 Index 從 1 開始

7 t <- read.table(“c:/55a.txt", head = T, sep=“\t”) type1 <- t[,2] boxplot(type1) class1class2 s15060 s24020 s37833 s43388 s59878 s6902 s722100

8 t <- read.table("c:/55a.txt", head = T, sep="\t") x <- t[,2] y <- t[,3] boxplot(cbind(x, y), col="lightgreen", main=“Score") class1class2 s15060 s24020 s37833 s43388 s59878 s6902 s722100

9


Download ppt "R. > log2(32) [1] 5 > sqrt(2) [1] 1.414214 > seq(0, 5, length=6) [1] 0 1 2 3 4 5 > plot(sin(seq(0, 2*pi, length=100)))"

Similar presentations


Ads by Google