Upasna Sharma
2005-Mar-09 21:02 UTC
[R] Dropping coloumns while redaing dtaa from text file.
Hi I have a huge text file and .dat file from which I want to read data. I do not need all the columns in the files. I want to extract only some columns from the .txt file or the .dat file, because reading the entire file is becoming very difficult due to memory issues. Is it possible to extract a few columns from .txt or .dat file while reading the data in R? Thanks Upasna -- "The past is a history, the future is a mystery, and this moment is a gift. That is why this moment is called 'the present'." Anonymous
Peter Dalgaard
2005-Mar-10 08:21 UTC
[R] Dropping coloumns while redaing dtaa from text file.
"Upasna Sharma" <upasna at iitb.ac.in> writes:> Hi > > I have a huge text file and .dat file from which I want to read data. I do > not need all the columns in the files. I want to extract only some columns > from the .txt file or the .dat file, because reading the entire file is > becoming very difficult due to memory issues. Is it possible to extract a > few columns from .txt or .dat file while reading the data in R?You're not sayin what tools you are using to read in the first place, but notice that the colClasses argument to read.table can have NULL elements. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Prof Brian Ripley
2005-Mar-10 08:28 UTC
[R] Dropping coloumns while redaing dtaa from text file.
On Thu, 10 Mar 2005, Upasna Sharma wrote:> Hi > > I have a huge text file and .dat file from which I want to read data. I do > not need all the columns in the files. I want to extract only some columns > from the .txt file or the .dat file, because reading the entire file is > becoming very difficult due to memory issues. Is it possible to extract a > few columns from .txt or .dat file while reading the data in R?Yes. Look at the use of NULL for 'colClasses' (read.table) or 'what' (scan), and also 'flush'. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595