emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] With R using ":var d=data" breaks ":colnames yes" [9.7-pre (release_9.6.10-881-g595a32]
@ 2024-03-06 23:09 Paul Stansell
  2024-03-07 13:20 ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Stansell @ 2024-03-06 23:09 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 14806 bytes --]

Hello,

It seems that using ":var d=data" breaks ":colnames yes" in the header of
an R code block.

In the example below the first code block uses ":colnames yes" and gives
the correct output, the second code block uses ":var d=data" to read the
data in the table (although it read the header as data), and the third code
uses both ":colnames yes" and ":var d=data" but gives the error "Wrong type
argument: sequencep, hline".

Thanks,

Paul

# ================= Start example =====================
#+name: data
|--------+--------|
|      x |      y |
|--------+--------|
| 111.89 |  88.37 |
| 392.12 | 297.33 |
|--------+--------|

This code block works as expected.
#+begin_src R --no-save --no-restore :colnames yes
  data.frame(x=1, y=2)
#+end_src

#+RESULTS:
| x | y |
|---+---|
| 1 | 2 |


This code block shows that the data in the table can be read (although
the table header is read as data).
#+begin_src R --no-save --no-restore :var d=data
  d
#+end_src

#+RESULTS:
|      x |      y |
| 111.89 |  88.37 |
| 392.12 | 297.33 |


However, using both ":colnames yes" and ":var d=data" together gives
an error "Wrong type argument: sequencep, hline"
#+begin_src R --no-save --no-restore :colnames yes :var d=data
  data.frame(x=1, y=2)
#+end_src
# ================= End example =====================



Emacs  : GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.33, cairo version 1.16.0)
 of 2023-08-16, modified by Debian
Package: Org mode version 9.7-pre (release_9.6.10-881-g595a32 @
/home/ps/.emacs.d_Kubuntu-23.04/org-mode-git/lisp/)

current state:
==============
(setq
 org-src-mode-hook '(org-src-babel-configure-edit-buffer
org-src-mode-configure-edit-buffer)
 org-link-shell-confirm-function 'yes-or-no-p
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-html-format-inlinetask-function
'org-html-format-inlinetask-default-function
 org-odt-format-headline-function 'org-odt-format-headline-default-function
 org-persist-before-write-hook '(org-element--cache-persist-before-write)
 org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
 org-startup-folded t
 org-id-link-to-org-use-id t
 org-mode-hook '((closure
                  (org-agenda-skip-regexp org-fold-core-style
org-table1-hline-regexp
                   org-table-tab-recognizes-table\.el
org-table-dataline-regexp
                   org-table-any-border-regexp
org-agenda-restriction-lock-overlay
                   org-agenda-overriding-restriction org-agenda-diary-file
                   org-complex-heading-regexp calendar-mode-map t)
                  nil (setq imenu-create-index-function
'org-imenu-get-tree))
                 (closure
                  (org--rds reftex-docstruct-symbol org-attach-method
                   org--single-lines-list-is-paragraph
org-element-greater-elements
                   org-agenda-restrict-end org-agenda-restrict-begin
org-agenda-restrict
                   visual-fill-column-width org-clock-history
org-agenda-current-date
                   org-with-time org-defdecode org-def
org-read-date-inactive org-ans2
                   org-ans1 org-columns-current-fmt-compiled
org-clock-current-task
                   org-clock-effort org-agenda-skip-function
org-agenda-skip-comment-trees
                   org-agenda-archives-mode org-end-time-was-given
org-time-was-given
                   org-log-note-extra org-log-note-purpose
org-log-post-message
                   org-last-inserted-timestamp org-last-changed-timestamp
                   org-entry-property-inherited-from org-state
                   org-agenda-headline-snapshot-before-repeat
org-agenda-buffer-name
                   org-agenda-start-on-weekday org-agenda-buffer-tmp-name
                   org-priority-regexp org-mode-abbrev-table
org-element-cache-persistent
                   org-element-cache-version buffer-face-mode-face
org-tbl-menu org-org-menu
                   org-struct-menu org-entities org-last-state
org-id-track-globally
                   org-clock-start-time texmathp-why remember-data-file
                   org-agenda-tags-todo-honor-ignore-options
calc-embedded-open-mode
                   calc-embedded-open-formula calc-embedded-close-formula
                   align-mode-rules-list org-emphasis-alist
org-emphasis-regexp-components
                   org-export-registered-backends org-modules crm-separator
                   org-babel-load-languages org-id-overriding-file-name
                   org-indent-indentation-per-level
org-element--timestamp-regexp
                   org-element-cache-map-continue-from
org-element-paragraph-separate
                   org-agenda-buffer-name org-inlinetask-min-level t)
                  nil (add-hook 'change-major-mode-hook 'org-fold-show-all
'append 'local))
                 (closure
                  (org-src-window-setup *this*
org-babel-confirm-evaluate-answer-no
                   org-babel-tangle-uncomment-comments org-src-lang-modes
                   org-edit-src-content-indentation
org-babel-library-of-babel t)
                  nil
                  (add-hook 'change-major-mode-hook
#'org-babel-show-result-all 'append
                   'local)
                  )
                 org-babel-result-hide-spec org-babel-hide-all-hashes)
 org-clock-persist 'history
 org-odt-format-drawer-function '(closure
                                  (hfy-user-sheet-assoc hfy-html-quote-regex
                                   hfy-html-quote-map hfy-face-to-css
hfy-begin-span-handler
                                   hfy-end-span-handler archive-zip-extract
                                   nxml-auto-insert-xml-declaration-flag t)
                                  (_name contents) contents)
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-persist-before-read-hook '(org-element--cache-persist-before-read)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-clock-history-length 28
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-persist-after-read-hook '(org-element--cache-persist-after-read)
 org-bibtex-headline-format-function 'org-bibtex-headline-format-default
 org-adapt-indentation t
 org-latex-format-drawer-function '(closure
                                    (engrave-faces-latex-mathescape
                                     engrave-faces-current-preset-style
                                     engrave-faces-latex-output-style t)
                                    (_ contents) contents)
 org-babel-pre-tangle-hook '(save-buffer)
 org-file-apps '((auto-mode . emacs) ("\\.odt\\'" . "libreoffice %s")
                 ("\\.docx\\'" . "libreoffice %s") ("\\.xlsx\\'" .
"libreoffice %s")
                 ("\\.png\\'" . "xv %s") ("\\.jpg\\'" . "xv %s")
("\\.jpeg\\'" . "xv %s")
                 ("\\.webp\\'" . "xv %s") ("\\.pdf\\'" . "okular \"%s\"")
                 ("\\.xoj" . "xournal %s") ("\\.xopp" . "xournalpp %s"))
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe
org-babel-header-arg-expand)
 org-export-with-drawers '("LATEX_DRAW")
 org-hide-leading-stars t
 org-babel-load-languages '((R . t) (emacs-lisp . t) (gnuplot . t) (octave
. t) (python . t)
                            (fortran . t) (sql . t) (ditaa . t) (dot . t)
(shell . t))
 org-log-done 'time
 org-highlight-latex-and-related '(latex)
 org-ascii-format-drawer-function '(closure (t) (_name contents _width)
contents)
 org-cycle-tab-first-hook '(org-babel-hide-result-toggle-maybe
org-babel-header-arg-expand)
 org-agenda-loop-over-headlines-in-active-region nil
 org-fontify-done-headline nil
 org-fold-core-isearch-open-function 'org-fold--isearch-reveal
 org-occur-hook '(org-first-headline-recenter)
 org-log-into-drawer t
 org-cycle-hook '(org-cycle-hide-archived-subtrees
org-cycle-show-empty-lines
                  org-cycle-optimize-window-after-visibility-change
                  org-cycle-display-inline-images)
 org-todo-keywords '((sequence "TODO(t!)" "MAYBE(m!)" "STARTED(s!)"
"WAITING(w@/!)" "|"
                      "DONE(d)" "INFO(i!)" "CANCELLED(c@)" "UNFINISHED(u@)"
"ABANDONED(a@)")
                     )
 org-speed-command-hook '(org-speed-command-activate
org-babel-speed-command-activate)
 org-yank-image-file-name-function 'org-yank-image-autogen-filename
 org-odt-format-inlinetask-function
'org-odt-format-inlinetask-default-function
 org-fold-catch-invisible-edits 'error
 org-babel-tangle-lang-exts '(("fortran" . "F90") ("python" . "py")
("emacs-lisp" . "el")
                              ("elisp" . "el"))
 org-format-latex-options '(:foreground "Yellow" :background default :scale
1.2
                            :html-foreground "Black" :html-background
"Transparent"
                            :html-scale 1.07 :matchers ("begin" "$1" "$"
"$$" "\\(" "\\["))
 org-clock-display-default-range 'untilnow
 org-export-before-parsing-hook '(org-attach-expand-links)
 org-confirm-shell-link-function 'yes-or-no-p
 org-link-parameters '(("attachment" :follow org-attach-follow :complete
                        org-attach-complete-link)
                       ("eww" :follow org-eww-open :store
org-eww-store-link)
                       ("rmail" :follow org-rmail-open :store
org-rmail-store-link)
                       ("mhe" :follow org-mhe-open :store
org-mhe-store-link)
                       ("irc" :follow org-irc-visit :store
org-irc-store-link :export
                        org-irc-export)
                       ("info" :follow org-info-open :export
org-info-export :store
                        org-info-store-link :insert-description
                        org-info-description-as-command)
                       ("gnus" :follow org-gnus-open :store
org-gnus-store-link)
                       ("docview" :follow org-docview-open :export
org-docview-export :store
                        org-docview-store-link)
                       ("bibtex" :follow org-bibtex-open :store
org-bibtex-store-link)
                       ("bbdb" :follow org-bbdb-open :export
org-bbdb-export :complete
                        org-bbdb-complete-link :store org-bbdb-store-link)
                       ("w3m" :store org-w3m-store-link)
                       ("doi" :follow org-link-doi-open :export
org-link-doi-export)
                       ("id" :follow org-id-open :store
org-id-store-link-maybe)
                       ("file+sys") ("file+emacs") ("shell" :follow
org-link--open-shell)
                       ("news" :follow
                        (closure
                         ((scheme . "news") (--dolist-tail--) org-ts-regexp
                          org-src-source-file-name org-outline-regexp-bol
                          org-inhibit-startup org-id-link-to-org-use-id
org-highlight-links
                          org-comment-string org-agenda-buffer-name
                          clean-buffer-list-kill-buffer-names t)
                         (url arg) (browse-url (concat scheme ":" url) arg))
                        )
                       ("mailto" :follow
                        (closure
                         ((scheme . "mailto") (--dolist-tail--)
org-ts-regexp
                          org-src-source-file-name org-outline-regexp-bol
                          org-inhibit-startup org-id-link-to-org-use-id
org-highlight-links
                          org-comment-string org-agenda-buffer-name
                          clean-buffer-list-kill-buffer-names t)
                         (url arg) (browse-url (concat scheme ":" url) arg))
                        )
                       ("https" :follow
                        (closure
                         ((scheme . "https") (--dolist-tail--) org-ts-regexp
                          org-src-source-file-name org-outline-regexp-bol
                          org-inhibit-startup org-id-link-to-org-use-id
org-highlight-links
                          org-comment-string org-agenda-buffer-name
                          clean-buffer-list-kill-buffer-names t)
                         (url arg) (browse-url (concat scheme ":" url) arg))
                        )
                       ("http" :follow
                        (closure
                         ((scheme . "http") (--dolist-tail--) org-ts-regexp
                          org-src-source-file-name org-outline-regexp-bol
                          org-inhibit-startup org-id-link-to-org-use-id
org-highlight-links
                          org-comment-string org-agenda-buffer-name
                          clean-buffer-list-kill-buffer-names t)
                         (url arg) (browse-url (concat scheme ":" url) arg))
                        )
                       ("ftp" :follow
                        (closure
                         ((scheme . "ftp") (--dolist-tail--) org-ts-regexp
                          org-src-source-file-name org-outline-regexp-bol
                          org-inhibit-startup org-id-link-to-org-use-id
org-highlight-links
                          org-comment-string org-agenda-buffer-name
                          clean-buffer-list-kill-buffer-names t)
                         (url arg) (browse-url (concat scheme ":" url) arg))
                        )
                       ("help" :follow org-link--open-help :store
org-link--store-help)
                       ("file" :complete org-link-complete-file)
                       ("elisp" :follow org-link--open-elisp))
 org-latex-format-headline-function
'org-latex-format-headline-default-function
 org-link-elisp-confirm-function 'yes-or-no-p
 org-todo-keyword-faces '(("TODO" :foreground "light pink" :weight bold)
                          ("MAYBE" :foreground "light pink" :weight bold)
                          ("STARTED" :foreground "gold" :weight bold)
                          ("DONE" :foreground "light green" :weight bold)
                          ("WAITING" :foreground "gold" :weight bold)
                          ("CANCELLED" :foreground "light green" :weight
bold)
                          ("UNFINISHED" :foreground "light green" :weight
bold)
                          ("ABANDONED" :foreground "light green" :weight
bold))
 org-latex-format-inlinetask-function
'org-latex-format-inlinetask-default-function
 org-html-format-drawer-function '(closure
                                   (htmlize-buffer-places
org-html-format-table-no-css
                                    htmlize-css-name-prefix
htmlize-output-type
                                    htmlize-output-type
htmlize-css-name-prefix t)
                                   (_name contents) contents)
 org-clock-into-drawer "CLOCK"
 org-clock-in-switch-to-state "STARTED"
 org-html-format-headline-function
'org-html-format-headline-default-function
 org-clock-out-remove-zero-time-clocks t
 org-confirm-babel-evaluate nil
 )

[-- Attachment #2: Type: text/html, Size: 18811 bytes --]

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

* Re: [BUG] With R using ":var d=data" breaks ":colnames yes" [9.7-pre (release_9.6.10-881-g595a32]
  2024-03-06 23:09 [BUG] With R using ":var d=data" breaks ":colnames yes" [9.7-pre (release_9.6.10-881-g595a32] Paul Stansell
@ 2024-03-07 13:20 ` Ihor Radchenko
  2024-03-07 18:38   ` Paul Stansell
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2024-03-07 13:20 UTC (permalink / raw)
  To: Paul Stansell; +Cc: emacs-orgmode

Paul Stansell <paulstansell@gmail.com> writes:

> It seems that using ":var d=data" breaks ":colnames yes" in the header of
> an R code block.
> ...
> #+name: data
> |--------+--------|
> |      x |      y |
> |--------+--------|
> | 111.89 |  88.37 |
> | 392.12 | 297.33 |
> |--------+--------|

It is expected.
:colnames yes implies:

     The ‘colnames’ header argument accepts ‘yes’, ‘no’, or ‘nil’
     values.  The default value is ‘nil’: if an input table has column
     names--because the second row is a horizontal rule--then Org
     removes the column names, processes the table, puts back the column
     names, and then writes the table to the results block.  Using
     ‘yes’, Org does the same to the first row, even if the initial
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     table does not contain any horizontal rule.  When set to ‘no’, Org
     does not pre-process column names at all.

In your table, the first row is a horizontal line, so Org tries to parse
the first line as column names. And fails, of course.

I guess that we can make `org-babel-get-colnames' smarter and make it
skip the leading hlines.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
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>


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

* Re: [BUG] With R using ":var d=data" breaks ":colnames yes" [9.7-pre (release_9.6.10-881-g595a32]
  2024-03-07 13:20 ` Ihor Radchenko
@ 2024-03-07 18:38   ` Paul Stansell
  2024-03-07 19:05     ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Stansell @ 2024-03-07 18:38 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1691 bytes --]

Hi Ihor,

Thanks for your advice, it helps a lot.  Sorry for submitting
something that wasn't a bug.

Paul

On Thu, 7 Mar 2024 at 13:16, Ihor Radchenko <yantar92@posteo.net> wrote:

> Paul Stansell <paulstansell@gmail.com> writes:
>
> > It seems that using ":var d=data" breaks ":colnames yes" in the header of
> > an R code block.
> > ...
> > #+name: data
> > |--------+--------|
> > |      x |      y |
> > |--------+--------|
> > | 111.89 |  88.37 |
> > | 392.12 | 297.33 |
> > |--------+--------|
>
> It is expected.
> :colnames yes implies:
>
>      The ‘colnames’ header argument accepts ‘yes’, ‘no’, or ‘nil’
>      values.  The default value is ‘nil’: if an input table has column
>      names--because the second row is a horizontal rule--then Org
>      removes the column names, processes the table, puts back the column
>      names, and then writes the table to the results block.  Using
>      ‘yes’, Org does the same to the first row, even if the initial
>      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>      table does not contain any horizontal rule.  When set to ‘no’, Org
>      does not pre-process column names at all.
>
> In your table, the first row is a horizontal line, so Org tries to parse
> the first line as column names. And fails, of course.
>
> I guess that we can make `org-babel-get-colnames' smarter and make it
> skip the leading hlines.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> 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>
>

[-- Attachment #2: Type: text/html, Size: 2494 bytes --]

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

* Re: [BUG] With R using ":var d=data" breaks ":colnames yes" [9.7-pre (release_9.6.10-881-g595a32]
  2024-03-07 18:38   ` Paul Stansell
@ 2024-03-07 19:05     ` Ihor Radchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2024-03-07 19:05 UTC (permalink / raw)
  To: Paul Stansell; +Cc: emacs-orgmode

Paul Stansell <paulstansell@gmail.com> writes:

> Thanks for your advice, it helps a lot.  Sorry for submitting
> something that wasn't a bug.

While not a bug, the situation can certainly be improved.
Things should be a bit smarter on main after
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=cab81f242

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
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>


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

end of thread, other threads:[~2024-03-07 19:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-06 23:09 [BUG] With R using ":var d=data" breaks ":colnames yes" [9.7-pre (release_9.6.10-881-g595a32] Paul Stansell
2024-03-07 13:20 ` Ihor Radchenko
2024-03-07 18:38   ` Paul Stansell
2024-03-07 19:05     ` Ihor Radchenko

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).