Q:

Building a data frame with sentences of different lengths

I want to build a Data Frame with for example 9 columns and I am using a log file as my input. For the first 8 columns I know that the file is neatly separated by spaces. But column 9 is a message that is made of words and variables and is also separated by spaces.  
V1  V2       V3        V4        V5     V6     V7 V8                V9

1a lo_Out [12/4/15 12:36:01:367 GMT] 000000be con J   This is a message N characters long
1a lo_In  [12/4/15 12:36:01:403 GMT] 0000008c Com W   This is a message N characters long
2a lo_Out [12/4/15 12:36:01:404 GMT] 0000008c con J   This is a message N characters long
2a lo_In  [12/4/15 12:36:01:404 GMT] 000000be Com X   This is a message N characters long

So, Can I read in the file and stop my code trying to separate on the last column and just dump the leftovers into the last column?
This is what I did with a similar Apache common logs format ... but with this all the vectors were the same length.  It's that message that's separated by spaces that's killing me here.  Is Data Frame even the right way to go about this? 
### First read in the logfile
logfile <- 'logfile.net-Nov-2015';

data_dt <- fread(logfile, sep = ' ');

### Load and rename important columns
data_dt[, ip_address  := as.character(V1)];
data_dt[, timestamp   := paste(V4, V5)];
data_dt[, request     := V6];
data_dt[, http_status := V7];
data_dt[, return_size := V8];
data_dt[, referer     := V9];
data_dt[, user_agent  := V10];

A:

Try using the quote option in read.table:
data_dt <- read.table(logfile, sep = " ", quote = "\"", header = FALSE)

For more details, read the docs: read.table
EDIT:
In case you don't have quoted strings, you can try reconstructing the ninth column as follows.
First, let's use some reproducible data to test with, which can be stored in a file called "log.txt". The single letters represents your words.
logfile_content <- "aaa bbb ccc ddd eee fff ggg hhh i j k
aaa bbb ccc ddd eee fff ggg hhh l m
aaa bbb ccc ddd eee fff ggg hhh 
aaa bbb ccc ddd eee fff ggg hhh n o p q r s t
aaa bbb ccc ddd eee fff ggg hhh u
"
write(logfile_content, "log.txt")

Read the file with extra arguments. fill will generate the missing values for those rows with a number of columns less than the maximum. na.strings will convert those missing values into NA. stringsAsFactors is used to work with plain strings. 
data_dt <- read.table("log.txt", sep = " ", header = FALSE, 
                      fill = TRUE, stringsAsFactors = FALSE, na.strings = "")

To reconstruct the last column you can apply the paste function to each row.
V9 <- apply(data_dt[,9:ncol(data_dt)], MARGIN=1, FUN=function(v) paste(na.omit(v), collapse=" "))

Then you can combine your first 8 columns with the ninth reconstructed
(data_dt2 <- cbind(data_dt[,1:8], V9))
   V1  V2  V3  V4  V5  V6  V7  V8            V9
1 aaa bbb ccc ddd eee fff ggg hhh         i j k
2 aaa bbb ccc ddd eee fff ggg hhh           l m
3 aaa bbb ccc ddd eee fff ggg hhh              
4 aaa bbb ccc ddd eee fff ggg hhh n o p q r s t
5 aaa bbb ccc ddd eee fff ggg hhh             u

Please note, if your log file is huge this may not perform very well. I am pretty sure something like this can be better achieved with data.table but I don't know how. Hopefully this is a good start for you.

