R——图形初阶

图形初阶

1
2
3
4
5
6
7
8
## 使用图形
attach(mtcars)
png("txcj1.png")
plot(wt, mpg)
abline(lm(mpg~wt))
title("Regression of MPG on Weight")
dev.off()
detach(mtcars)

R——创建数据集

向量矩阵数组数据框

1
2
3
4
5
6
7
8
9
10
11
12
13
14
## 向量
a <- c(1,2,3,4,5)
b <- c("one", "two", "three")
c <- c(TRUE, TRUE, FALSE, FALSE)
## 矩阵
# 默认按列排
d <- matrix(1:20, nrow = 5, ncol = 4)
d
e <- matrix(1:20, nrow = 5, byrow = TRUE)
e

cells <- c(1,2,3,5)
rnames <- c("R1", "R2")
cnames <- c("C1", "C2")
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×