为什么多列显示为R中的一个向量

问题描述 投票:0回答:1

我尝试运行以下代码时尝试从URL读取数据:

x <- read.csv(url(myUrl), sep = '\t', head = FALSE)
print(x)

我知道了

                         V1      V2
1   18.0   8   30.7   130.0   hello
2   32.0   6   23.5   121.5   bye

而且我想要这个

      V1    V2     V3      V4      V5 
1   18.0   8.0   30.7   130.0   hello
2   32.0   6.0   23.5   121.5   bye

由于某种原因,它读取为2列而不是5列

编辑1

这里是网址中的数据文件的片段:

enter image description here

编辑2这是网址:https://archive.ics.uci.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.data

r
1个回答
1
投票

代替\t,可能是,使用' ',或者未指定分隔符

x <- read.table(url(myUrl), header = FALSE)
© www.soinside.com 2019 - 2024. All rights reserved.