2020-08-23
阅读量:
3046
数据框的创建和访问
数据框也是一张二维表格,行和列在统计上分别称为观测和变量,计算机上分别称为记录和域。变量名的对应称谓是域名,变量值对应域值
创建数据框
data.frame(域名1=向量名1,域名2=向量名2,….)
names(数据框名)
访问数据框
数据框名$域名、数据框名[[“域名”]]、数据框名[[域编号]]
attach函数和detach函数、with函数
> male<-c(124,88,200)
> female<-c(108,56,221)
> degree<-c("low","middle","high")
> myopia<-data.frame(degree,female,male)
> myopia
degree female male
1 low 108 124
2 middle 56 88
3 high 221 200
访问
> myopia$degree
[1] low middle high
Levels: high low middle
> myopia[["degree"]]
[1] low middle high
Levels: high low middle
> myopia[[1]]
[1] low middle high
Levels: high low middle






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论