Skip to content
Prev 281077 / 398503 Next

[newbie] read row from file into vector

The scan function can be used to read a single row.  If your file has multiple rows you can use the skip and nlines arguments to determine which row to read.  With the what argument sent to a single item (a number or string depending on which you want) it will read each element on that row into a vector.

If you want to do more of the hard work yourself you can read in a whole line as a single string using the readLines function then use the strsplit (or possibly better, tools from the gsubfun package) to split that string into a vector (the unlist function may also be of help).