有没有办法强制 R 读取具有特定列数的 table ,以便它填充所有列?

Is there a way to coerce R into reading a table with a specific number of columns, so that it fills all columns?

我正在尝试将 this table 读入 R。

我知道我可以跳过前 x 行以忽略序言。

使用此代码:

read.table("https://www.physics.mcmaster.ca/~harris/GCS_table.txt",
              header = T,
              sep = "\t",
              skip = 36)

我遇到的问题是 R 将所有数据放入一列,而不是将其拆分为不同的列。

我注意到列 headers,一旦我将它们读入 R,似乎由小数点分隔,所以我尝试过:

read.table("https://www.physics.mcmaster.ca/~harris/GCS_table.txt",
              header = F,
              sep = "\t",
              skip = 38)

避免 header - 这更好,但它仍然强制所有内容进入一列。

我尝试了所有我能想到的 "sep" 论点,但没有成功。

有没有办法让 R 填满 x 列?还是我的 "sep" 论点有问题?

我不太确定 rows/column 你希望在 table 中有多少,但你可以试试

data.table::fread("https://www.physics.mcmaster.ca/~harris/GCS_table.txt",
                   header = TRUE,skip = 36)

或者

read.table("https://www.physics.mcmaster.ca/~harris/GCS_table.txt",
            header = TRUE,skip = 36, fill = TRUE)