emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Re: [babel] problem with colnames
  2012-05-08 18:55 [babel] problem with colnames Andreas Leha
@ 2012-05-08 17:57 ` Eric Schulte
  2012-05-08 20:26   ` Andreas Leha
  2012-05-08 19:16 ` Thomas S. Dye
  1 sibling, 1 reply; 5+ messages in thread
From: Eric Schulte @ 2012-05-08 17:57 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

Andreas Leha <andreas.leha@med.uni-goettingen.de> 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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [babel] problem with colnames
@ 2012-05-08 18:55 Andreas Leha
  2012-05-08 17:57 ` Eric Schulte
  2012-05-08 19:16 ` Thomas S. Dye
  0 siblings, 2 replies; 5+ messages in thread
From: Andreas Leha @ 2012-05-08 18:55 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [babel] problem with colnames
  2012-05-08 18:55 [babel] problem with colnames Andreas Leha
  2012-05-08 17:57 ` Eric Schulte
@ 2012-05-08 19:16 ` Thomas S. Dye
  2012-05-08 19:26   ` Andreas Leha
  1 sibling, 1 reply; 5+ messages in thread
From: Thomas S. Dye @ 2012-05-08 19:16 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

Aloha Andreas,

Andreas Leha <andreas.leha@med.uni-goettingen.de> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [babel] problem with colnames
  2012-05-08 19:16 ` Thomas S. Dye
@ 2012-05-08 19:26   ` Andreas Leha
  0 siblings, 0 replies; 5+ messages in thread
From: Andreas Leha @ 2012-05-08 19:26 UTC (permalink / raw)
  To: emacs-orgmode

tsd@tsdye.com (Thomas S. Dye) writes:

> Aloha Andreas,
>
> Andreas Leha <andreas.leha@med.uni-goettingen.de> 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
>


Hi Tom,

thanks for your confirmation.

Regards,
Andreas

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [babel] problem with colnames
  2012-05-08 17:57 ` Eric Schulte
@ 2012-05-08 20:26   ` Andreas Leha
  0 siblings, 0 replies; 5+ messages in thread
From: Andreas Leha @ 2012-05-08 20:26 UTC (permalink / raw)
  To: emacs-orgmode

Eric Schulte <eric.schulte@gmx.com> writes:

> Andreas Leha <andreas.leha@med.uni-goettingen.de> 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?

Definitely.  Just as Tom also suggested.  I would very much welcome such
new feature.

Regards,
Andreas

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-05-08 20:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-08 18:55 [babel] problem with colnames Andreas Leha
2012-05-08 17:57 ` Eric Schulte
2012-05-08 20:26   ` Andreas Leha
2012-05-08 19:16 ` Thomas S. Dye
2012-05-08 19:26   ` Andreas Leha

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).