[R] write merged data frame to a file

David Winsemius dwinsemius at comcast.net
Mon Jul 18 19:36:26 CEST 2011


On Jul 18, 2011, at 11:10 AM, Andrea Franceschini wrote:

> Dear Philipp,
>
>
> You were right,
> thankyou very much.
> Effectively the second read.table didn't work (probably because of the
> strange characters).
>> From my point of view this is a very bad R bug.

When I read this I thought it was an example of a young person just  
starting their education exhibiting Piaget's "preoperational" stage  
when applied to the task of learning a computer language.

"the child begins to use symbols to represent objects. Early in this  
stage he also personifies objects. [snipped]  His thinking is  
influenced by fantasy -- the way he'd like things to be -- and he  
assumes that others see situations from his viewpoint."

[Copied from a webpage for grade school teachers: http://www2.honolulu.hawaii.edu/facdev/guidebk/teachtip/piaget.htm 
  ]

But when I do a search in PubMed, I find that you may be an  
established researcher, so I thing the onus is now on you to  
demonstrate how R's behavior is different than the documented design  
goals for the read.table function.

> I precisely inserted the "\t" separator in the read table command,
> hence I would expect that everything is working.
> How can I make it work ???

I thought Pagel already gave you the answer, but your response is too  
general to be sure. What exactly did you find and can you provide a  
minimal code and data example that illustrates how read.table is  
acting in any way different than the documentation describes?

-- 
David.


> Effectively there are several ' (i.e. apostrophe) characters in the
> file. I guess are those that confuse R
>
>
> Thankyou very much,
> Best Regards,
> Andrea
>
>
>
>
> On Mon, Jul 18, 2011 at 4:32 PM, Philipp Pagel <p.pagel at wzw.tum.de>  
> wrote:
>> On Mon, Jul 18, 2011 at 04:00:29PM +0200, Andrea Franceschini wrote:
>>>
>>> I use version 13 of R in OSX (downloaded and installed less than 1  
>>> year ago).
>>
>> Probably 2.13 ...
>>
>> [...] code omitted
>>
>>> The first lines are OK (i.e. 14 columns, like the dataframe),  
>>> while at
>>> a certain point I get lines with only 3 columns !!!
>>> The bad lines that contain only 3 columns have the name and the
>>> description of the gene (i.e. the content of the file that I merged
>>> with).
>>> Besides, these strange lines also get repeated (see the bottom).
>>
>> I havent't carefully analyzed your code so I may be wrong but my  
>> guess for
>> all "weird behaviour of gene related data.frames" problems is this:
>>
>> Gene descriptions love to contain things like "Foo 5' obfuscation
>> factor".  Note the "'" in the description which read.table will
>> happily interpret as a quotation mark and eat lots of rows until it
>> happens to encouter a closing counterpart. This leads to all kinds of
>> funny results. So I bet your problem is not in write.table but in
>> reading the data. Have a closer look at your data frame: are you
>> really getting the expected number of observations in the merged
>> data.frame? Are the rows in question really ok in the data frame? If
>> my guess is correct you should be able to fix your problem by
>> including quote="" in both your read.table commands.
>>
>> If it doesn't, also try comment.char="" - another popular source of
>> problems.
>>
>> cu
>>        Philipp
>>
>> --
>> Dr. Philipp Pagel
>> Lehrstuhl für Genomorientierte Bioinformatik
>> Technische Universität München
>> Wissenschaftszentrum Weihenstephan
>> 85350 Freising, Germany
>> http://webclu.bio.wzw.tum.de/~pagel/
>>
>
> ______________________________________________
> 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list