[R] Problem loading a txt file as a data.frame
Charles C. Berry
cberry at tajo.ucsd.edu
Tue Oct 2 21:05:13 CEST 2007
On Tue, 2 Oct 2007, Ettinger, Nicholas wrote:
> Hello all,
>
> I know that this is a terribly banal question but I cannot seem to solve
> it.
>
> 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)
You have specified neither quote nor comment.char.
The default for quote is "\"'". You might try changing it to "" or "\"".
>
> The problem is that this text file should load with 118 rows, 7 columns
> of data. But when I execute the following command:
>
>> dim(MDMT_RPup)
> I only get:
>> 40 7
Look at each of the rows. Where things start going crazy you need to
inspect the data.
You might use readLines() and cat() to read in and inspect the data rather
than a text editor.
HTH,
Chuck
>
> Other similarly generated text files of varying sizes (9 rows, 72 rows,
> etc.) seem to load just fine.
>
> 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.
>
> Any ideas?
> --Nick
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
Charles C. Berry (858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
More information about the R-help
mailing list