[R] re ading specific columns
dwinsemius at comcast.net
Tue Nov 18 07:55:35 CET 2008
On Nov 18, 2008, at 12:57 AM, kayj wrote:
> I have a huge txt file and I only want to get out of it column 3
> and 7.
> I tried to read the whole file and then extract the two columns, but
> I ran
> into a memory problem since the file is huge.
> Is it possible just to tell R to read these two columns without
> reading the
> whole file?
?read.table # read the documentation for colClasses carefully
something along the lines of:
in.frame <- read.table(file = "c//folder/filename.ext", colClasses =
c("NULL","NULL","character", "NULL", "NULL","NULL","NULL","character"))
You need to add as many NULLs as there are additional records in the
longest input line. It may be helpful to first run count.fields(). You
might get a more specific answer if you defined "huge". You should
also look at the FAQ regarding memory issues. There are also database
oriented solutions available.
> View this message in context: http://www.nabble.com/reading-specific-columns-tp20554049p20554049.html
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help