From mboxrd@z Thu Jan 1 00:00:00 1970 From: tsd@tsdye.com (Thomas S. Dye) Subject: Re: [babel] problem with colnames Date: Tue, 08 May 2012 09:16:08 -1000 Message-ID: References: <87r4uu33ks.fsf@med.uni-goettingen.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([208.118.235.92]:49229) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SRptY-0007bc-K1 for emacs-orgmode@gnu.org; Tue, 08 May 2012 15:16:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SRptW-0000iK-E9 for emacs-orgmode@gnu.org; Tue, 08 May 2012 15:16:24 -0400 Received: from oproxy8-pub.bluehost.com ([69.89.22.20]:34127) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1SRptW-0000i3-4T for emacs-orgmode@gnu.org; Tue, 08 May 2012 15:16:22 -0400 In-Reply-To: <87r4uu33ks.fsf@med.uni-goettingen.de> (Andreas Leha's message of "Tue, 08 May 2012 20:55:31 +0200") 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 Aloha Andreas, 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? I don't think this is possible with the current ob-r.el. I found this problem a few months ago and have been working around it since then. I think the solution is to patch ob-r.el so the :colnames header argument has 4 states: none, input, output, both. All the best, Tom > > > 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 > > > -- Thomas S. Dye http://www.tsdye.com