[R] Problem loading a txt file as a data.frame
Prof Brian Ripley
ripley at stats.ox.ac.uk
Fri Oct 5 18:44:09 CEST 2007
The first-round answer to such questions is to try read.delim().
Why? Because the issues are often comment characters (#) or quotes(').
It is also possible that you have unmatched ", but that usually indicates
something more serious.
On Fri, 5 Oct 2007, Ettinger, Nicholas wrote:
> Hello all,
> I know that this is a terribly banal question but I cannot seem to solve
> I am trying to load in data from a tab-delimited text file. Some
> columns are mixed text-numbers and other columns are strictly numbers.
> Some cells are blank.
> My command is:
>> MDMT_RPup <- read.table("GCRMA_MDM-T_RPup.txt", header=T,
> sep="\t", row.names=NULL, fill=TRUE)
> The problem is that this text file should load with 118 rows, 7 columns
> of data. But when I execute the following command:
> I only get:
>> 40 7
> Other similarly generated text files of varying sizes (9 rows, 72 rows,
> etc.) seem to load just fine with the appropriate number of rows.
> I have tried opening the text file in MS Excel and deleting all columns
> to the right of the data in case there was some kind of hidden
> character. No help.
> I realize that this is a small problem, but I'm stumped.
> Thanks in advance for any help!
> [[alternative HTML version deleted]]
> 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.
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
More information about the R-help