读取以分号分隔的文件 [英] Reading a semicolon-separated file
本文介绍了读取以分号分隔的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试读取以;"分隔的csv文件.从以下位置- http://archive.ics.uci.edu/ml/数据集/银行+营销
I am trying to read a csv file that is separated by ";" from the following location - http://archive.ics.uci.edu/ml/datasets/Bank+Marketing
我尝试同时使用read.csv(data,sep =;")和read.csv2(data,dec =."),但是它没有用,它读取的文件只有1列.
I have tried to use both read.csv(data,sep=";") and read.csv2(data,dec="."), but it has not worked and it reads the file as having 1 column.
我做错了什么,我怎么能让R读到它?
What am I doing wrong and how could I get R to read this?
谢谢!
推荐答案
目前尚不清楚您要读取的数据集.以下代码从您的URL下载和解压缩banks-full
数据集,请检查以下内容:
It's not clear what dataset you're trying to read. The following code downloads and unzips banks-full
dataset from your URL, check this out:
temp <- tempfile()
download.file("http://archive.ics.uci.edu/ml/machine-learning-databases/00222/bank.zip",temp, mode="wb")
unzip(temp, "bank-full.csv")
unlink(temp)
bank.df <- read.table("bank-full.csv", sep=";", header=T)
str(bank.df)
# 'data.frame': 45211 obs. of 17 variables:
这篇关于读取以分号分隔的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文