emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [BUG] ob-R.el: extra empty data.frame columns generated from plain l


From: Jeremie Juste
Subject: Re: [BUG] ob-R.el: extra empty data.frame columns generated from plain lists after recent change [9.6 (release_9.6-3-ga4d38e @ /usr/share/emacs/30.0.50/lisp/org/)]
Date: Tue, 06 Dec 2022 23:11:56 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux)

Hello,

Many thanks for the insights. I confess that I have never transferred
list from org to R before. I've always use tables and as far as I
understand they works fine in 9.6.

So assuming this list

#+name: alist 
- first item
- second item
- third item
  - 3.1 item
- fourth item


before c72d5ee84 we could do something like 

#+begin_src R :var list=alist
  list
#+end_src

#+RESULTS:
| first item  |                        |
| second item |                        |
| third item  | (unordered (3.1 item)) |
| fourth item |                        |

and after we end up with 


#+begin_src R :var list=alist
  list
#+end_src

#+RESULTS:
| first item | second item | third item | fourth item |   |   |   |   |   |   |

Here I'm on uncharted territory. We could go with 
1.
| first item | second item | third item | fourth item |

or be closer to the version 9.5 with
2. 
| first item  | 
| second item | 
| third item  | 
| fourth item | 

However I'm still tempted to choose the second option to break as little
workflow as possible.

If we go in this direction the solution of Chuck works fine. Many thanks
for the suggestions.

> @@ -241,7 +241,7 @@ This function is called by `org-babel-execute-src-block'."
> (defun org-babel-R-assign-elisp (name value colnames-p rownames-p)
>   "Construct R code assigning the elisp VALUE to a variable named NAME."
>   (if (listp value)
> -      (let* ((lengths (mapcar 'length (cl-remove-if-not 'sequencep value)))
> +      (let* ((lengths (mapcar 'length (cl-remove-if-not 'listp value)))
>            (max (if lengths (apply 'max lengths) 0))
>            (min (if lengths (apply 'min lengths) 0)))
>         ;; Ensure VALUE has an orgtbl structure (depth of at least 2).

-         (unless (listp (car value)) (setq value (list value)))
+         (unless (listp (car value)) (setq value (mapcar 'list value)))



Do you have any case of using org-list to R? Do you think we could use
the list for a different purpose.  Suggestions are welcome.

Best regards,
Jeremie








On Sunday,  4 Dec 2022 at 18:49, Greg Minshall wrote:
> for the record, these are the tests i ran with my off-the-cuff "fix"
> (s/sequencep/listp/):
> ----
>
> #+name: alist
> - first item
>
> - second item
> - third item
>
> #+begin_src R :var list=alist :session ss
>  list
> #+end_src
>
>
> #+RESULTS:
> | first item | second item | third item |
>
> #+begin_src R :var variable='(a test)
>   variable
> #+end_src
>
>
> #+RESULTS:
> | a | test |
>
> #+name: atable
> | this | is | a | header | line |
>
> |------+----+---+--------+------|
> | 1    | 2  | 3 | 4      | 5    |
> | a    | b  | c | d      | e    |
>
> #+begin_src R :var list=atable :session ss
>  list
> #+end_src
>
>
> #+RESULTS:
> | 1 | 2 | 3 | 4 | 5 |
> | a | b | c | d | e |
>
> #+begin_src R :var list='((1 2 3) (1 2))
>   list
> #+end_src
>
>
> #+RESULTS:
> | 1 | 2 | 3 |
> | 1 | 2 |   |
>
> #+begin_src elisp :var list=alist
>  list
> #+end_src
>
> #+RESULTS:
> | first item | second item | third item |



reply via email to

[Prev in Thread] Current Thread [Next in Thread]