I would recommend the function input.filefrom the "iotools" package.
Usage will be something like this:
library(iotools)
input.file("yourfile.txt", formatter = dstrsplit, nsep = " ", col_types = "character")
Here is an example. (I just created a dummy temporary file in my workspace for the purpose of illustration).
x <- tempfile()
writeLines(c("0001 This is text for 0001",
"0002 This has spaces in between",
"0003 Yet this is only supposed to be two columns",
"0009 Why didn't they just comma delimit you may ask?",
"0010 Or even use quotations?",
"001 Who knows",
"0012 But now I'm here with his file",
"0013 And hoping someone has an elegant solution?"), con = x)
library(iotools)
input.file(x, formatter = dstrsplit, nsep = " ", col_types = "character")
Elegant enough ?; -)
Update 1
data.frame ( @Jaap), "iotools" , , input.file.
, :
dstrsplit(as.character(mydf$V1), nsep = " ", col_types = "character")
2
, - , , Jaap, akrun "iotools" . this Gist. : , "iotoos" - . tomtom, , .