From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: [babel] problem with colnames Date: Tue, 08 May 2012 13:57:17 -0400 Message-ID: <877gwmimib.fsf@gmx.com> References: <87r4uu33ks.fsf@med.uni-goettingen.de> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:32804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SRqXU-0003Ux-3I for emacs-orgmode@gnu.org; Tue, 08 May 2012 15:57:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SRqXQ-0000z1-T5 for emacs-orgmode@gnu.org; Tue, 08 May 2012 15:57:39 -0400 Received: from mailout-us.gmx.com ([74.208.5.67]:49648) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1SRqXQ-0000yn-MP for emacs-orgmode@gnu.org; Tue, 08 May 2012 15:57:36 -0400 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Andreas Leha Cc: emacs-orgmode@gnu.org Andreas Leha writes: > Hi all, > > I have a question regarding colnames in babel source blocks. > > Suppose, I have a source block (in R) that has as input a table and returns a > table. And I would like to have the resulting table with column > names, but the input table does not have column names. > > How can I achieve this? > > > Here is an example: > > The input table > > #+name: intab > | bla | > | blu | > > > By default, the colnames are stripped off the result: > > #+begin_src R :var intab=intab > colnames(intab) <- "rara" > > intab > #+end_src > > #+results: > | bla | > | blu | > > > The same happens when setting :colnames no > > #+begin_src R :var intab=intab :colnames no > colnames(intab) <- "rara" > > intab > #+end_src > > #+results: > | bla | > | blu | > > > Setting :colnames yes strips the first row from the input: > > #+begin_src R :var intab=intab :colnames yes > colnames(intab) <- "rara" > > intab > #+end_src > > #+results: > | rara | > |------| > | blu | > > > Finally, setting :colnames nil also strips the first row from the input: > > #+begin_src R :var intab=intab :colnames nil > colnames(intab) <- "rara" > > intab > #+end_src > > #+results: > | rara | > |------| > | blu | > > > Regards, > Andreas > > It almost seems like there should be two columnames options, one for input and one for output. This would add complexity but would make use cases like yours above feasible. Does this sound reasonable? Best, -- Eric Schulte http://cs.unm.edu/~eschulte/