我对LendingClub的历史数据很感兴趣,它是最大的P2P贷款公司。
这是一个非标准化的压缩CSB文件,但当在Excel中打开时,可以通过删除第1行、39789-39791行和42543-42544行轻松地进行补救,我如何在R中自动完成?(如果你想帮忙,但担心这可能是恶意链接,请先搜索这家公司)
我尝试了以下几点:
data <- read.csv(url("https://resources.lendingclub.com/LoanStats3a.csv.zip"))但它会抛出错误:
Error in read.table(file = file, header = header, sep = sep, quote = quote, :
duplicate 'row.names' are not allowed发布于 2014-10-23 01:12:06
您可以使用skip通过第一个“垃圾”行,但是在后面有4个“垃圾”行,您需要处理导入后的代码:
dat <- read.csv("LoanStats3a.csv", skip=1, header=TRUE, stringsAsFactors=FALSE)
str(dat)
## 'data.frame': 42538 obs. of 96 variables:
## $ id : chr "1077501" "1077430" "1077175" "1076863" ...
## $ member_id : int 1296599 1314167 1313524 1277178 1311748 1311441 1304742 1288686 1306957 1306721 ...
## $ loan_amnt : int 5000 2500 2400 10000 3000 5000 7000 3000 5600 5375 ...
## $ funded_amnt : int 5000 2500 2400 10000 3000 5000 7000 3000 5600 5375 ...
## $ funded_amnt_inv : num 4975 2500 2400 10000 3000 ...
## $ term : chr " 36 months" " 60 months" " 36 months" " 36 months" ...
## $ int_rate : chr " 10.65%" " 15.27%" " 15.96%" " 13.49%" ...
## $ installment : num 162.9 59.8 84.3 339.3 67.8 ...
## $ grade : chr "B" "C" "C" "C" ...
## $ sub_grade : chr "B2" "C4" "C5" "C1" ...
## $ emp_title : chr "" "Ryder" "" "AIR RESOURCES BOARD" ...
## $ emp_length : chr "10+ years" "< 1 year" "10+ years" "10+ years" ...
## ... (a bunch more variables, some are all NA)https://stackoverflow.com/questions/26517216
复制相似问题