* [BUG] [babel] [R] :colnames yes conflicts with :results file @ 2015-01-06 12:40 Andreas Leha 2015-01-06 13:49 ` Rainer M Krug 0 siblings, 1 reply; 10+ messages in thread From: Andreas Leha @ 2015-01-06 12:40 UTC (permalink / raw) To: emacs-orgmode Hi all, There seems to be a bug in babel (at least for R) when it comes to source blocks producing file links but taking tables with headers. In that case, ':colnames yes' disables the ':results file' directive. Here is the Cm: --8<---------------cut here---------------start------------->8--- * test #+BEGIN_SRC R :results file replace "some_file.csv" #+END_SRC #+RESULTS: [[file:some_file.csv]] #+BEGIN_SRC R :colnames yes :results file replace "some_file.csv" #+END_SRC #+RESULTS: | x | |---------------| | some_file.csv | * My Setup #+begin_src emacs-lisp (concat (replace-regexp-in-string " on .*" "" (emacs-version)) "\n" (replace-regexp-in-string " @.*" ")" (org-version nil t)) "\n" (replace-regexp-in-string "].*" "]" (ess-version))) #+end_src #+RESULTS: : GNU Emacs 24.4.50.1 (x86_64-apple-darwin13.3.0, NS appkit-1265.21 Version 10.9.4 (Build 13E28)) : of 2014-09-02 : Org-mode version 8.3beta (release_8.3beta-717-ga8096c) : ess-version: 14.05 [git: 4283f1304a54502c42707b6a4ba347703f0992dd] --8<---------------cut here---------------end--------------->8--- Regards, Andreas ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [BUG] [babel] [R] :colnames yes conflicts with :results file 2015-01-06 12:40 [BUG] [babel] [R] :colnames yes conflicts with :results file Andreas Leha @ 2015-01-06 13:49 ` Rainer M Krug 2015-01-06 15:39 ` Andreas Leha 2015-01-06 16:01 ` Thomas S. Dye 0 siblings, 2 replies; 10+ messages in thread From: Rainer M Krug @ 2015-01-06 13:49 UTC (permalink / raw) To: Andreas Leha; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 2216 bytes --] Andreas Leha <andreas.leha@med.uni-goettingen.de> writes: > Hi all, Hi > > There seems to be a bug in babel (at least for R) when it comes to > source blocks producing file links but taking tables with headers. In > that case, ':colnames yes' disables the ':results file' directive. I don't think this is a bug as it is not clear what should happen. In the org manual it states concerning the :results file ,---- | * `file' The results will be interpreted as the path to a file, and | will be inserted into the Org mode buffer as a file link. E.g., | `:results value file'. `---- But the :colnames only works on tables (i.e. :results table) - but the result is represented as a link to a file. So what should happen? If you would like to have a table with links to files, the easiest is to put the file names into [[]] in R and then return them in a table - or use :results output and "draw" the table. But as it stands, these two header arguments do not go together. It would be nice to have a warning (or even error) in org, or at least a table of header argument precedence. By the way - never used the :results file - but now I will! Thanks. Hope this helps, Rainer > > Here is the Cm: > * test > > #+BEGIN_SRC R :results file replace > "some_file.csv" > #+END_SRC > > #+RESULTS: > [[file:some_file.csv]] > > #+BEGIN_SRC R :colnames yes :results file replace > "some_file.csv" > #+END_SRC > > #+RESULTS: > | x | > |---------------| > | some_file.csv | > > > > * My Setup > #+begin_src emacs-lisp > (concat > (replace-regexp-in-string " on .*" "" (emacs-version)) > "\n" > (replace-regexp-in-string " @.*" ")" (org-version nil t)) > "\n" > (replace-regexp-in-string "].*" "]" (ess-version))) > #+end_src > > #+RESULTS: > : GNU Emacs 24.4.50.1 (x86_64-apple-darwin13.3.0, NS appkit-1265.21 Version 10.9.4 (Build 13E28)) > : of 2014-09-02 > : Org-mode version 8.3beta (release_8.3beta-717-ga8096c) > : ess-version: 14.05 [git: 4283f1304a54502c42707b6a4ba347703f0992dd] > > Regards, > Andreas > > > -- Rainer M. Krug email: Rainer<at>krugs<dot>de PGP: 0x0F52F982 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 494 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [BUG] [babel] [R] :colnames yes conflicts with :results file 2015-01-06 13:49 ` Rainer M Krug @ 2015-01-06 15:39 ` Andreas Leha 2015-01-06 17:50 ` Aaron Ecay 2015-01-07 9:11 ` Rainer M Krug 2015-01-06 16:01 ` Thomas S. Dye 1 sibling, 2 replies; 10+ messages in thread From: Andreas Leha @ 2015-01-06 15:39 UTC (permalink / raw) To: emacs-orgmode Hi Rainer, Thanks for following up on this. Rainer M Krug <Rainer@krugs.de> writes: > Andreas Leha <andreas.leha@med.uni-goettingen.de> writes: > >> Hi all, > > Hi > >> >> There seems to be a bug in babel (at least for R) when it comes to >> source blocks producing file links but taking tables with headers. In >> that case, ':colnames yes' disables the ':results file' directive. > > I don't think this is a bug as it is not clear what should happen. I disagree. I consider it a bug because it is a functional limitation. If I see it correctly, there is no way to generate a file link when passing a table with header. I'd expect the :colnames yes to take effect only if there is actually a table. If that was the behaviour, then there would be no functional limitation of that kind. > In the org manual it states concerning the :results file > > ,---- > | * `file' The results will be interpreted as the path to a file, and > | will be inserted into the Org mode buffer as a file link. E.g., > | `:results value file'. > `---- > > But the :colnames only works on tables (i.e. :results table) - but the > result is represented as a link to a file. So what should happen? Well, I think -- as you say -- :colnames works only on tables. Since there is no table (more than that, actually: I specifically do *not want* a table), the :colnames should not apply. I ask org to produce a file link but get a table. For me that clearly is unexpected. > > If you would like to have a table with links to files, the easiest is to > put the file names into [[]] in R and then return them in a table - or > use :results output and "draw" the table. Exactly. > > But as it stands, these two header arguments do not go together. > > It would be nice to have a warning (or even error) in org, or at least a > table of header argument precedence. I'd say a warning does not fix this. As I might need ':colnames yes' for an input table and ':results file' for the output. At least that is my view. Thanks, Andreas > > By the way - never used the :results file - but now I will! Thanks. > > Hope this helps, > > Rainer > > >> >> Here is the Cm: >> * test >> >> #+BEGIN_SRC R :results file replace >> "some_file.csv" >> #+END_SRC >> >> #+RESULTS: >> [[file:some_file.csv]] >> >> #+BEGIN_SRC R :colnames yes :results file replace >> "some_file.csv" >> #+END_SRC >> >> #+RESULTS: >> | x | >> |---------------| >> | some_file.csv | >> >> >> >> * My Setup >> #+begin_src emacs-lisp >> (concat >> (replace-regexp-in-string " on .*" "" (emacs-version)) >> "\n" >> (replace-regexp-in-string " @.*" ")" (org-version nil t)) >> "\n" >> (replace-regexp-in-string "].*" "]" (ess-version))) >> #+end_src >> >> #+RESULTS: >> : GNU Emacs 24.4.50.1 (x86_64-apple-darwin13.3.0, NS appkit-1265.21 Version 10.9.4 (Build 13E28)) >> : of 2014-09-02 >> : Org-mode version 8.3beta (release_8.3beta-717-ga8096c) >> : ess-version: 14.05 [git: 4283f1304a54502c42707b6a4ba347703f0992dd] >> >> Regards, >> Andreas >> >> >> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [BUG] [babel] [R] :colnames yes conflicts with :results file 2015-01-06 15:39 ` Andreas Leha @ 2015-01-06 17:50 ` Aaron Ecay 2015-01-07 9:11 ` Rainer M Krug 1 sibling, 0 replies; 10+ messages in thread From: Aaron Ecay @ 2015-01-06 17:50 UTC (permalink / raw) To: Andreas Leha, emacs-orgmode Hi Andreas, 2015ko urtarrilak 6an, Andreas Leha-ek idatzi zuen: [...] > > I'd say a warning does not fix this. As I might need ':colnames yes' > for an input table and ':results file' for the output. > > > At least that is my view. I agree, FWIW. -- Aaron Ecay ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [BUG] [babel] [R] :colnames yes conflicts with :results file 2015-01-06 15:39 ` Andreas Leha 2015-01-06 17:50 ` Aaron Ecay @ 2015-01-07 9:11 ` Rainer M Krug 1 sibling, 0 replies; 10+ messages in thread From: Rainer M Krug @ 2015-01-07 9:11 UTC (permalink / raw) To: Andreas Leha; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 3997 bytes --] Andreas Leha <andreas.leha@med.uni-goettingen.de> writes: > Hi Rainer, > > Thanks for following up on this. > > Rainer M Krug <Rainer@krugs.de> writes: >> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes: >> >>> Hi all, >> >> Hi >> >>> >>> There seems to be a bug in babel (at least for R) when it comes to >>> source blocks producing file links but taking tables with headers. In >>> that case, ':colnames yes' disables the ':results file' directive. >> >> I don't think this is a bug as it is not clear what should happen. > > I disagree. I consider it a bug because it is a functional limitation. > If I see it correctly, there is no way to generate a file link when > passing a table with header. > > I'd expect the :colnames yes to take effect only if there is actually a > table. If that was the behaviour, then there would be no functional > limitation of that kind. OK - I see your point. I was only thinking of the R -> org side, but :colnames yes also refers to the input side. So if I understand you correctly, you want org -> R tables with header as variables R -> org link to file Is this correct? In this case, I agree completely - this is a bug. > > >> In the org manual it states concerning the :results file >> >> ,---- >> | * `file' The results will be interpreted as the path to a file, and >> | will be inserted into the Org mode buffer as a file link. E.g., >> | `:results value file'. >> `---- >> >> But the :colnames only works on tables (i.e. :results table) - but the >> result is represented as a link to a file. So what should happen? > > Well, I think -- as you say -- :colnames works only on tables. Since > there is no table (more than that, actually: I specifically do *not > want* a table), the :colnames should not apply. Agree completely. > > I ask org to produce a file link but get a table. For me that clearly > is unexpected. > +1 >> >> If you would like to have a table with links to files, the easiest is to >> put the file names into [[]] in R and then return them in a table - or >> use :results output and "draw" the table. > > Exactly. > >> >> But as it stands, these two header arguments do not go together. >> >> It would be nice to have a warning (or even error) in org, or at least a >> table of header argument precedence. > > I'd say a warning does not fix this. As I might need ':colnames yes' > for an input table and ':results file' for the output. So if the results type is defined, :results determines the type of the returned value, and only if it is a table, the :colnames header argument should be used. > > > At least that is my view. Your view is correct. Cheers, Rainer > > Thanks, > Andreas > > >> >> By the way - never used the :results file - but now I will! Thanks. >> >> Hope this helps, >> >> Rainer >> >> >>> >>> Here is the Cm: >>> * test >>> >>> #+BEGIN_SRC R :results file replace >>> "some_file.csv" >>> #+END_SRC >>> >>> #+RESULTS: >>> [[file:some_file.csv]] >>> >>> #+BEGIN_SRC R :colnames yes :results file replace >>> "some_file.csv" >>> #+END_SRC >>> >>> #+RESULTS: >>> | x | >>> |---------------| >>> | some_file.csv | >>> >>> >>> >>> * My Setup >>> #+begin_src emacs-lisp >>> (concat >>> (replace-regexp-in-string " on .*" "" (emacs-version)) >>> "\n" >>> (replace-regexp-in-string " @.*" ")" (org-version nil t)) >>> "\n" >>> (replace-regexp-in-string "].*" "]" (ess-version))) >>> #+end_src >>> >>> #+RESULTS: >>> : GNU Emacs 24.4.50.1 (x86_64-apple-darwin13.3.0, NS appkit-1265.21 Version 10.9.4 (Build 13E28)) >>> : of 2014-09-02 >>> : Org-mode version 8.3beta (release_8.3beta-717-ga8096c) >>> : ess-version: 14.05 [git: 4283f1304a54502c42707b6a4ba347703f0992dd] >>> >>> Regards, >>> Andreas >>> >>> >>> > > > -- Rainer M. Krug email: Rainer<at>krugs<dot>de PGP: 0x0F52F982 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 494 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [BUG] [babel] [R] :colnames yes conflicts with :results file 2015-01-06 13:49 ` Rainer M Krug 2015-01-06 15:39 ` Andreas Leha @ 2015-01-06 16:01 ` Thomas S. Dye 2015-01-07 9:19 ` Rainer M Krug 2015-01-07 9:33 ` Sebastien Vauban 1 sibling, 2 replies; 10+ messages in thread From: Thomas S. Dye @ 2015-01-06 16:01 UTC (permalink / raw) To: Rainer M Krug; +Cc: Andreas Leha, emacs-orgmode Aloha Rainer, Rainer M Krug <Rainer@krugs.de> writes: > I don't think this is a bug as it is not clear what should happen. > In the org manual it states concerning the :results file > > ,---- > | * `file' The results will be interpreted as the path to a file, and > | will be inserted into the Org mode buffer as a file link. E.g., > | `:results value file'. > `---- > > But the :colnames only works on tables (i.e. :results table) - but the > result is represented as a link to a file. So what should happen? I think this is mistaken. "Tables" occur in at least three contexts in babel source code blocks. There are input tables, :var mytable, there are "tables" within the code block, represented in R as a dataframe or a matrix, and there are output tables, which are placed in the Org mode buffer as a result. I use :colnames to keep the column names of input tables associated with the "tables" within the code block, and typically have them represented in the output, whether that is a "table" written to file, or output to the Org mode buffer as an Org mode table, either by default or (more rarely) through use of :results table. In my experience :results table is mostly useful for coercing a value that babel would otherwise interpret as a scalar into a single element table. > If you would like to have a table with links to files, the easiest is to > put the file names into [[]] in R and then return them in a table - or > use :results output and "draw" the table. > > But as it stands, these two header arguments do not go together. Which two header arguments? :results table file is contradictory, but :colnames yes :results file is not, or should not be, IMHO. All the best, Tom -- Thomas S. Dye http://www.tsdye.com ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [BUG] [babel] [R] :colnames yes conflicts with :results file 2015-01-06 16:01 ` Thomas S. Dye @ 2015-01-07 9:19 ` Rainer M Krug 2015-01-07 17:14 ` Thomas S. Dye 2015-01-07 9:33 ` Sebastien Vauban 1 sibling, 1 reply; 10+ messages in thread From: Rainer M Krug @ 2015-01-07 9:19 UTC (permalink / raw) To: Thomas S. Dye; +Cc: Andreas Leha, emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 2241 bytes --] tsd@tsdye.com (Thomas S. Dye) writes: > Aloha Rainer, > > Rainer M Krug <Rainer@krugs.de> writes: > >> I don't think this is a bug as it is not clear what should happen. >> In the org manual it states concerning the :results file >> >> ,---- >> | * `file' The results will be interpreted as the path to a file, and >> | will be inserted into the Org mode buffer as a file link. E.g., >> | `:results value file'. >> `---- >> >> But the :colnames only works on tables (i.e. :results table) - but the >> result is represented as a link to a file. So what should happen? > > I think this is mistaken. "Tables" occur in at least three contexts in > babel source code blocks. There are input tables, :var mytable, there > are "tables" within the code block, represented in R as a dataframe or a > matrix, and there are output tables, which are placed in the Org mode > buffer as a result. Agreed - I was only thinking of the R -> org path. > > I use :colnames to keep the column names of input tables associated with > the "tables" within the code block, and typically have them represented > in the output, whether that is a "table" written to file, or output to > the Org mode buffer as an Org mode table, either by default or (more > rarely) through use of :results table. > > In my experience :results table is mostly useful for coercing a value > that babel would otherwise interpret as a scalar into a single element > table. Well - if the result is an R data.frame, it would not make a difference if I use :results table or not - correct? > >> If you would like to have a table with links to files, the easiest is to >> put the file names into [[]] in R and then return them in a table - or >> use :results output and "draw" the table. >> >> But as it stands, these two header arguments do not go together. > > Which two header arguments? :results table file is contradictory, but > :colnames yes :results file is not, or should not be, IMHO. Yup - ~:colnames yes :results file~ as well as ~:colnames yes :results table~ are not Cheers, Rainer > > All the best, > Tom -- Rainer M. Krug email: Rainer<at>krugs<dot>de PGP: 0x0F52F982 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 494 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [BUG] [babel] [R] :colnames yes conflicts with :results file 2015-01-07 9:19 ` Rainer M Krug @ 2015-01-07 17:14 ` Thomas S. Dye 0 siblings, 0 replies; 10+ messages in thread From: Thomas S. Dye @ 2015-01-07 17:14 UTC (permalink / raw) To: Rainer M Krug; +Cc: Andreas Leha, emacs-orgmode Rainer M Krug <Rainer@krugs.de> writes: > Well - if the result is an R data.frame, it would not make a difference > if I use :results table or not - correct? This is how I understand it. Because an R data.frame looks like a table, the babel default is to represent it as a table in the results. However, Babel interprets the single-cell table as a scalar. #+begin_src R :results value ret <- data.frame("scalar") #+end_src #+results: : scalar #+begin_src R :results value table ret <- data.frame("table") #+end_src #+results: | table | hth, Tom -- Thomas S. Dye http://www.tsdye.com ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [BUG] [babel] [R] :colnames yes conflicts with :results file 2015-01-06 16:01 ` Thomas S. Dye 2015-01-07 9:19 ` Rainer M Krug @ 2015-01-07 9:33 ` Sebastien Vauban 2015-01-07 13:45 ` Rainer M Krug 1 sibling, 1 reply; 10+ messages in thread From: Sebastien Vauban @ 2015-01-07 9:33 UTC (permalink / raw) To: emacs-orgmode-mXXj517/zsQ Thomas S. Dye wrote: > Rainer M Krug <Rainer-vfylz/Ys1k4@public.gmane.org> writes: >> But the :colnames only works on tables (i.e. :results table) - but >> the result is represented as a link to a file. So what should happen? > > I think this is mistaken. "Tables" occur in at least three contexts > in babel source code blocks. There are input tables, :var mytable, > there are "tables" within the code block, represented in R as > a dataframe or a matrix, and there are output tables, which are placed > in the Org mode buffer as a result. > > I use :colnames to keep the column names of input tables associated > with the "tables" within the code block, and typically have them > represented in the output, whether that is a "table" written to file, > or output to the Org mode buffer as an Org mode table, either by > default or (more rarely) through use of :results table. > > In my experience :results table is mostly useful for coercing a value > that babel would otherwise interpret as a scalar into a single element > table. Another problem, IIUC, is that :colnames serves to specify both input and output, right? Or can you well declare that, for example, the input table has an header, but to strip it from the output?? Best regards, Seb -- Sebastien Vauban ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [BUG] [babel] [R] :colnames yes conflicts with :results file 2015-01-07 9:33 ` Sebastien Vauban @ 2015-01-07 13:45 ` Rainer M Krug 0 siblings, 0 replies; 10+ messages in thread From: Rainer M Krug @ 2015-01-07 13:45 UTC (permalink / raw) To: Sebastien Vauban; +Cc: public-emacs-orgmode-mXXj517/zsQ [-- Attachment #1: Type: text/plain, Size: 1884 bytes --] Sebastien Vauban <sva-news-D0wtAvR13HarG/iDocfnWg@public.gmane.org> writes: > Thomas S. Dye wrote: >> Rainer M Krug <Rainer-vfylz/Ys1k4@public.gmane.org> writes: >>> But the :colnames only works on tables (i.e. :results table) - but >>> the result is represented as a link to a file. So what should happen? >> >> I think this is mistaken. "Tables" occur in at least three contexts >> in babel source code blocks. There are input tables, :var mytable, >> there are "tables" within the code block, represented in R as >> a dataframe or a matrix, and there are output tables, which are placed >> in the Org mode buffer as a result. >> >> I use :colnames to keep the column names of input tables associated >> with the "tables" within the code block, and typically have them >> represented in the output, whether that is a "table" written to file, >> or output to the Org mode buffer as an Org mode table, either by >> default or (more rarely) through use of :results table. >> >> In my experience :results table is mostly useful for coercing a value >> that babel would otherwise interpret as a scalar into a single element >> table. > > Another problem, IIUC, is that :colnames serves to specify both input > and output, right? This would be the optimal solution - but instead of having a second header argument, the values ~input~ and ~output~ and ~both~ could be added, allowing to have headers only for input or output respectively, or for both (equivalent to ~yes~ at the moment, but clearer). > > Or can you well declare that, for example, the input table has an > header, but to strip it from the output?? I would prefer the option to be able to specify :colnames and :rownames for input and output separately. Cheers, Rainer > > Best regards, > Seb -- Rainer M. Krug email: Rainer<at>krugs<dot>de PGP: 0x0F52F982 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 494 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-01-07 17:14 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-01-06 12:40 [BUG] [babel] [R] :colnames yes conflicts with :results file Andreas Leha 2015-01-06 13:49 ` Rainer M Krug 2015-01-06 15:39 ` Andreas Leha 2015-01-06 17:50 ` Aaron Ecay 2015-01-07 9:11 ` Rainer M Krug 2015-01-06 16:01 ` Thomas S. Dye 2015-01-07 9:19 ` Rainer M Krug 2015-01-07 17:14 ` Thomas S. Dye 2015-01-07 9:33 ` Sebastien Vauban 2015-01-07 13:45 ` Rainer M Krug
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).