R 导入 .data 文件扩展名
R import .data file extension
您好,我正在尝试从 URL:https://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data 导入数据,但它始终将其导入为单行。我用“\t”分割数据,但它仍然不起作用。我的 R 代码;
bostonHousing <- read.table("https://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data",
col.names= c("CRIM","ZN","INDUS","CHAS","NOX","RM","AGE","DIS","RAD","TAX","PTRATIO","B","LSTAT","MEDV"),
dec=",",sep = "\t")
该文件不是制表符分隔的,而是白色space 分隔的。默认情况下,read.table
假定列由一个或多个白色 space 字符分隔(制表符 或 space)。仅当列以制表符分隔 和 数据列可能包含嵌入的 space 时,才真正需要指定制表符分隔符(或使用 read.delim()
)...
url <- "https://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data"
bostonHousing <- read.table(url)
似乎工作正常(dec=","
也是一个坏主意)
您好,我正在尝试从 URL:https://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data 导入数据,但它始终将其导入为单行。我用“\t”分割数据,但它仍然不起作用。我的 R 代码;
bostonHousing <- read.table("https://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data",
col.names= c("CRIM","ZN","INDUS","CHAS","NOX","RM","AGE","DIS","RAD","TAX","PTRATIO","B","LSTAT","MEDV"),
dec=",",sep = "\t")
该文件不是制表符分隔的,而是白色space 分隔的。默认情况下,read.table
假定列由一个或多个白色 space 字符分隔(制表符 或 space)。仅当列以制表符分隔 和 数据列可能包含嵌入的 space 时,才真正需要指定制表符分隔符(或使用 read.delim()
)...
url <- "https://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data"
bostonHousing <- read.table(url)
似乎工作正常(dec=","
也是一个坏主意)