数据的导入与预处理

1.数据的导入

用于导入数据的R函数:

.使用R包自带数据

.读取csv文件:read.table和它的cousins

.不规则数据:readLines

.读取excel文件:xlsx包/read.xlsx

.读取spss文件:foreign包/read.spss

.读取sas文件:read.ssd

2.不规范数据的预处理

见代码:

#############download data from website, unzip data########
#############read data from mutiple separate files
#美国国际开发署开发政府公开的原始数据
download.file(url="http://jaredlander.com/data/US_Foreign_Aid.zip",
              destfile="ForeignAid.zip")
unzip("ForeignAid.zip")
library(stringr)
dir()
theFiles=dir(pattern = "^US_Foreign_Aid")
theFiles
?regex
#loop through those files
for (a in theFiles)
{
  #build a good name to assign to data
  nameToUse=str_sub(string=a,start=12,end
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值