Re: [R] read.table mystery

2011-03-06 Thread Johannes Graumann
"count.fields" is a very nice hint for a clean solution - thank you! Joh On Sunday 06 March 2011 21:48:32 David Winsemius wrote: > On Mar 6, 2011, at 12:47 PM, Johannes Graumann wrote: > > Thank you for pointing this out. This is really inconvenient as I do > > not > > know a priori how many and

Re: [R] read.table mystery

2011-03-06 Thread David Winsemius
On Mar 6, 2011, at 12:47 PM, Johannes Graumann wrote: Thank you for pointing this out. This is really inconvenient as I do not know a priori how many and where those darn cases containing an additional (or more) ":" might be ... There is a count.fields function that might assist with this

Re: [R] read.table mystery

2011-03-06 Thread Johannes Graumann
Opted for a solution with 100 column names, which is unlikely to be met ... Thanks for your guidance. Joh On Sunday 06 March 2011 20:57:11 Sarah Goslee wrote: > You could pre-process your data into a more sensible format. > Or you could use scan to read each line of the file, count the number of

Re: [R] read.table mystery

2011-03-06 Thread Sarah Goslee
You could pre-process your data into a more sensible format. Or you could use scan to read each line of the file, count the number of colons, then use read.table with ncolons + 1 columns. Or you could use read.table with many more columns than are ever going to be in the data, then delete the empty

Re: [R] read.table mystery

2011-03-06 Thread Johannes Graumann
Thank you for pointing this out. This is really inconvenient as I do not know a priori how many and where those darn cases containing an additional (or more) ":" might be ... The seems to work, but will fail if there's a "1:sdfjhlfkh:2:adlkjf" somewhere (1 & 2 both integerable). na.exclude(as

Re: [R] read.table mystery

2011-03-06 Thread David Winsemius
On Mar 6, 2011, at 10:19 AM, Sarah Goslee wrote: Not so much a mystery. read.table() only looks at the first 5 lines when decided how many columns your file has (as described in the Details section of the help). The easiest solution is to add a col.names argument to read.table() with the

Re: [R] read.table mystery

2011-03-06 Thread Sarah Goslee
Not so much a mystery. read.table() only looks at the first 5 lines when decided how many columns your file has (as described in the Details section of the help). The easiest solution is to add a col.names argument to read.table() with the correct number of names. You may want to also include as.

[R] read.table mystery

2011-03-06 Thread Johannes Graumann
Hello, Please have a look at the code below, which I use to read in the attached file. As line 18 of the file reads "1065:>sp|Q9V3T9|ADRO_DROME NADPH:adrenodoxin oxidoreductase, mitochondrial OS=Drosophila melanogaster GN=dare PE=2 SV=1", I expect the code below to produce a 3 column data frame