Reputation: 76
I'm trying to read this table into R.
I know I can skip the first x number of lines to ignore the preamble.
Using this code:
read.table("https://www.physics.mcmaster.ca/~harris/GCS_table.txt",
header = T,
sep = "\t",
skip = 36)
I get the problem that R puts all the data into one column, and doesn't split it into different columns.
I noticed the column headers, once I've read them into R, seem to be separated by decimal points so I've tried:
read.table("https://www.physics.mcmaster.ca/~harris/GCS_table.txt",
header = F,
sep = "\t",
skip = 38)
to avoid the header - which is nicer, but it still forces everything into one column.
I've tried every "sep" argument I can think of, with no luck.
Is there a way I can tell R to fill up x number of columns? Or is this a problem with my "sep" argument?
Upvotes: 1
Views: 130
Reputation: 388972
I am not exactly sure how many rows/column you expect in the table but you can try either
data.table::fread("https://www.physics.mcmaster.ca/~harris/GCS_table.txt",
header = TRUE,skip = 36)
Or
read.table("https://www.physics.mcmaster.ca/~harris/GCS_table.txt",
header = TRUE,skip = 36, fill = TRUE)
Upvotes: 1