* bug: orgtbl-to-tsv: premature end of table
@ 2015-07-14 21:26 lom pik
2015-07-22 21:34 ` Charles C. Berry
0 siblings, 1 reply; 6+ messages in thread
From: lom pik @ 2015-07-14 21:26 UTC (permalink / raw
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1110 bytes --]
Hi,
-- this was only tested with the current git version
I was trying to export a table as a variable to R via babel evaluation.
However it seems that is the rows are empty , the exported table ends at
the last non-empty value.
For example,the second row of tbl-issue defined below ends with 2 columns
[8,9]. The next table however works ok. I've narrowed down the cause to the
orgtbl-to-tsv function as highlighted below.
#+NAME: tbl-issue
| 1 | 2 | 3 | 5 | 6 | 7 |
| 8 | 9 | | | | |
#+BEGIN_SRC R :session *R* :var df2=tbl-issue :results value ## won't
work
print(df2)
#+END_SRC
(orgtbl-to-tsv '( (1 2 #1="" #1# #1# #1# ) ) '(:fmt
org-babel-R-quote-tsv-field)) -> "\"1\"<tab>\"2\""
#+NAME: tlb-ok
| 1 | 2 | 3 | 5 | 6 | 7 |
| 8 | 9 | | | | 10 |
#+BEGIN_SRC R :session *R* :var df2=tbl-ok :results value # work ok
print(df2)
#+END_SRC
(orgtbl-to-tsv '( (1 2 #1="" #1# #1# #1# 10) ) '(:fmt
org-babel-R-quote-tsv-field)) ->
"\"1\"<tab>\"2\"<tab><tab><tab><tab><tab>\"1\""
Emacs 24.5 with Org-mode version 8.3beta
(release_8.3beta-1286-g20795f.dirty )
Regards,
lompik
[-- Attachment #2: Type: text/html, Size: 1588 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: bug: orgtbl-to-tsv: premature end of table
2015-07-14 21:26 bug: orgtbl-to-tsv: premature end of table lom pik
@ 2015-07-22 21:34 ` Charles C. Berry
2015-07-22 22:41 ` Nicolas Goaziou
0 siblings, 1 reply; 6+ messages in thread
From: Charles C. Berry @ 2015-07-22 21:34 UTC (permalink / raw
To: lom pik; +Cc: emacs-orgmode
On Tue, 14 Jul 2015, lom pik wrote:
> Hi,
>
> -- this was only tested with the current git version
>
> I was trying to export a table as a variable to R via babel evaluation.
> However it seems that is the rows are empty , the exported table ends at
> the last non-empty value.
>
> For example,the second row of tbl-issue defined below ends with 2 columns
> [8,9]. The next table however works ok. I've narrowed down the cause to the
> orgtbl-to-tsv function as highlighted below.
Not a bug IMO.
See the R documentation page for `read.table'. Note `fill'.
>
> #+NAME: tbl-issue
> | 1 | 2 | 3 | 5 | 6 | 7 |
> | 8 | 9 | | | | |
> #+BEGIN_SRC R :session *R* :var df2=tbl-issue :results value ## won't
> work
> print(df2)
> #+END_SRC
You have two options (at least):
1. Place `NA' in the last cell of the last line
2. add ' , fill=TRUE ' like this:
#+BEGIN_SRC emacs-lisp
(setq
ob-R-transfer-variable-table-with-header
"%s <- local({
con <- textConnection(
%S
)
res <- utils::read.table(
con,
header = %s,
row.names = %s,
sep = \"\\t\",
as.is = TRUE, fill=TRUE
)
close(con)
res
})")
#+END_SRC
Either way you will get:
#+RESULTS:
| 1 | 2 | 3 | 5 | 6 | 7 |
| 8 | 9 | nil | nil | nil | nil |
HTH,
Chuck
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: bug: orgtbl-to-tsv: premature end of table
2015-07-22 21:34 ` Charles C. Berry
@ 2015-07-22 22:41 ` Nicolas Goaziou
2015-07-22 23:17 ` lom pik
2015-07-23 4:04 ` Charles C. Berry
0 siblings, 2 replies; 6+ messages in thread
From: Nicolas Goaziou @ 2015-07-22 22:41 UTC (permalink / raw
To: Charles C. Berry; +Cc: emacs-orgmode, lom pik
Hello,
"Charles C. Berry" <ccberry@ucsd.edu> writes:
> Not a bug IMO.
Notwithstanding the R issue, I think trimming the output of a radio
table is a bit aggressive. We cannot know if trailing (and leading)
spaces are significant in the output format the user defined.
I removed the trimming part in commit
bf37cd09b128b4431e1dd1a538fbcc4be3615042.
Let me know if you disagree with that change.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: bug: orgtbl-to-tsv: premature end of table
2015-07-22 22:41 ` Nicolas Goaziou
@ 2015-07-22 23:17 ` lom pik
2015-07-23 4:04 ` Charles C. Berry
1 sibling, 0 replies; 6+ messages in thread
From: lom pik @ 2015-07-22 23:17 UTC (permalink / raw
To: Charles C. Berry, lom pik, emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 790 bytes --]
Hi
> removed the trimming part in commit
> bf37cd09b128b4431e1dd1a538fbcc4be3615042.
With this commit, issue is gone. This did not happen in previous org-mode
releases although all other proposed workarounds worked as well.
Regards.
lompik
On Wed, Jul 22, 2015 at 5:41 PM, Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:
> Hello,
>
> "Charles C. Berry" <ccberry@ucsd.edu> writes:
>
> > Not a bug IMO.
>
> Notwithstanding the R issue, I think trimming the output of a radio
> table is a bit aggressive. We cannot know if trailing (and leading)
> spaces are significant in the output format the user defined.
>
> I removed the trimming part in commit
> bf37cd09b128b4431e1dd1a538fbcc4be3615042.
>
> Let me know if you disagree with that change.
>
>
> Regards,
>
> --
> Nicolas Goaziou
>
[-- Attachment #2: Type: text/html, Size: 1663 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: bug: orgtbl-to-tsv: premature end of table
2015-07-22 22:41 ` Nicolas Goaziou
2015-07-22 23:17 ` lom pik
@ 2015-07-23 4:04 ` Charles C. Berry
2015-07-23 9:13 ` Andreas Leha
1 sibling, 1 reply; 6+ messages in thread
From: Charles C. Berry @ 2015-07-23 4:04 UTC (permalink / raw
To: Nicolas Goaziou; +Cc: emacs-orgmode, lom pik
On Wed, 22 Jul 2015, Nicolas Goaziou wrote:
> Hello,
>
> "Charles C. Berry" <ccberry@ucsd.edu> writes:
>
>> Not a bug IMO.
>
> Notwithstanding the R issue, I think trimming the output of a radio
> table is a bit aggressive. We cannot know if trailing (and leading)
> spaces are significant in the output format the user defined.
>
> I removed the trimming part in commit
> bf37cd09b128b4431e1dd1a538fbcc4be3615042.
>
> Let me know if you disagree with that change.
I don't think the change broke anything that wasn't already broken.
And my diagnosis was wrong - I was confused by a problem that remains:
`org-babel-R-assign-elisp' is broken. Ragged rows in a table are filled
with "" in each missing field; `org-table-to-lisp' returns a list of lists
of common length.
`org-babel-R-assign-elisp' inspects that list to see if any element vary
in length. But they do not, and therefore `max' and `min' in the let*
varlist are equal and later on `ob-R-transfer-variable-table-with-header'
is always used.
I think lom pik's example would not have failed had max and min differed
as `ob-R-transfer-variable-table-without-header' would have been used
instead.
R src blocks ought to render missing elements due to ragged rows in a
table as NA, but this isnt the current behavior for this table:
#+NAME: tbl-ragged
| 1 | 2 | a |
| 8 | 9 | |
It seems like the fix for this would be to prune any "" at the ends of
lists in the value arg when beginning `org-babel-R-assign-elisp'.
But I am tired, so I'll defer trying this till another time.
Best,
Chuck
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: bug: orgtbl-to-tsv: premature end of table
2015-07-23 4:04 ` Charles C. Berry
@ 2015-07-23 9:13 ` Andreas Leha
0 siblings, 0 replies; 6+ messages in thread
From: Andreas Leha @ 2015-07-23 9:13 UTC (permalink / raw
To: emacs-orgmode
Hi all,
"Charles C. Berry" <ccberry@ucsd.edu> writes:
> On Wed, 22 Jul 2015, Nicolas Goaziou wrote:
>
>> Hello,
>>
>> "Charles C. Berry" <ccberry@ucsd.edu> writes:
>>
>>> Not a bug IMO.
>>
>> Notwithstanding the R issue, I think trimming the output of a radio
>> table is a bit aggressive. We cannot know if trailing (and leading)
>> spaces are significant in the output format the user defined.
>>
>> I removed the trimming part in commit
>> bf37cd09b128b4431e1dd1a538fbcc4be3615042.
>>
>> Let me know if you disagree with that change.
>
> I don't think the change broke anything that wasn't already broken.
>
> And my diagnosis was wrong - I was confused by a problem that remains:
>
> `org-babel-R-assign-elisp' is broken. Ragged rows in a table are filled
> with "" in each missing field; `org-table-to-lisp' returns a list of lists
> of common length.
>
> `org-babel-R-assign-elisp' inspects that list to see if any element vary
> in length. But they do not, and therefore `max' and `min' in the let*
> varlist are equal and later on `ob-R-transfer-variable-table-with-header'
> is always used.
>
> I think lom pik's example would not have failed had max and min differed
> as `ob-R-transfer-variable-table-without-header' would have been used
> instead.
>
> R src blocks ought to render missing elements due to ragged rows in a
> table as NA, but this isnt the current behavior for this table:
>
> #+NAME: tbl-ragged
> | 1 | 2 | a |
>
> | 8 | 9 | |
>
> It seems like the fix for this would be to prune any "" at the ends of
> lists in the value arg when beginning `org-babel-R-assign-elisp'.
>
> But I am tired, so I'll defer trying this till another time.
>
> Best,
>
> Chuck
Thank you all for looking into this. I have seen this as well and the
manual work-around (to put sth into the last cell) was getting really
annoying -- especially if the table was auto-generated by sth else.
While looking at handling tables, could I suggest to switch to csv
instead of tsv for the table passing? I still see issues with tables
not separated. (This happens only in preview (C-c C-v v) and not when
executing the block.) I never had time to track this down, but I get
caught now and then. Using csv should be more robust in this regard.
Thanks,
Andreas
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-07-23 9:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-14 21:26 bug: orgtbl-to-tsv: premature end of table lom pik
2015-07-22 21:34 ` Charles C. Berry
2015-07-22 22:41 ` Nicolas Goaziou
2015-07-22 23:17 ` lom pik
2015-07-23 4:04 ` Charles C. Berry
2015-07-23 9:13 ` Andreas Leha
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.