Christian Moe <[email protected]> writes:
>> Christian Moe <[email protected]> writes:
>>
>>> But I realize I spoke too soon about the need to document it in the
>>> manual, since it's not implemented for all languages. It apparently
>>> still isn't for R. (Possibly for the good reason that one can and should
>>> use R colnames.)
>>
>> Looking at the code, it should. Can you provide a failing example?
>
> I haven't looked at the code, but it fails for me. The below examples
> try to match the output for the elisp example I posted before:
>
> #+RESULTS:
> | Odd | Even |
> |-----+------|
> | 1 | 2 |
> | 3 | 4 |
> | 5 | 6 |
>
> With an R data frame, the result has the R colnames, not the ones from
> the Babel colnames header.
>
> #+begin_src R :colnames '("Odd" "Even")
> data.frame(a=c(1,3,5),
> b=c(2,4,6))
> #+end_src
>
> #+RESULTS:
> | a | b |
> |---+---|
> | 1 | 2 |
> | 3 | 4 |
> | 5 | 6 |
>
> Not unreasonable, since R data frames already provide colnames.
>
> With a simple array, too, R's default "V<n>" colnames prevail:
>
> #+begin_src R :colnames '("Odd" "Even")
> t(array(1:6, dim=c(2,3)))
> #+end_src
>
> #+RESULTS:
> | V1 | V2 |
> |----+----|
> | 1 | 2 |
> | 3 | 4 |
> | 5 | 6 |
Looks like the culprit is in
(format org-babel-R-write-object-command
(if row-names-p "TRUE" "FALSE")
(if column-names-p
(if row-names-p "NA" "TRUE")
"FALSE")
(format "{function ()\n{\n%s\n}}()" body)
(org-babel-process-file-name tmp-file 'noquote))
That only considers TRUE/FALSE.
CCing the maintainer.
--
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>