2020-08-25
阅读量:
3114
外部数据的读取与保存
getwd() #查看工作路径 dir()#查看工作路径中存储的文件信息
文件--->更改工作路径#更改工作路径
(1)文本文档文件的读取:
read.table(file="数据.数据类型",header=T,sep=””)
str()#浏览存储类型和结构信息
names()#查看数据框的各域名
head()#前六行
> str(A)
'data.frame': 104 obs. of 5 variables:
$ holderage : int 22 22 23 23 22 23 22 23 23 24 ...
$ vehiclegroup: Factor w/ 4 levels "A","B","C","D": 1 1 1 2 1 1 2 2
$ vehicleage : Factor w/ 3 levels "0-3","4-7","8-9": 1 2 3 1 2 3 1 2
$ claimamt : int 2312 2256 1064 3720 1992 2304 1890 2880
$ nclaims : int 8 8 4 10 28 1 9 5 1 3 ...
将读入数据框的字符串由因子转换成字符串read.table(file="车险数据.tex",header=T,sep=””,
stringsAsFactors=F)






评论(0)


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