Re: state of the art in org-mode tables e.g. join, etc

2021-02-22 Thread Greg Minshall
Malcolm, thanks, and, yes, i'm of mixed mind, myself.  cheers, Greg



Re: Symolic link messes up org-attach?

2021-02-22 Thread TRS-80

On 2021-02-22 11:16, Henrik Frisk wrote:

Hi,

I have migrated from a OSX based system to a linux/debian system.


Welcome to the Free World!  :D


I have all my main org files in a directory ~/org and in OSX this was
a symbolic link to ~/a-hard-disk/org (it may have been an alias, ot
sure). In Ubuntu, however, I have lots of trouble with org-attach: I
attach a file using say copy and when I call C-c C-a o there are no
attachments. Sometimes it works but next time I open the file there
are no attachments. I experienced similar issues with links:

[[file:./img/myimage.png]]

was not found but a qualified path worked.

Could this be because of the symlink to my org directory? Is there a
better way to do it?


I do not use org-attach, but I do use a lot of symlinks (at the
underlying system level), and they never give me any trouble (for
whatever that's worth).

Cheers,
TRS-80



Re: error "Can’t expand minibuffer to full frame"

2021-02-22 Thread TRS-80

On 2021-02-22 09:42, Florian Lindner wrote:

Hello,
I try to configure my org mode (Org mode version  ( @
/lhome/lindnfl/.emacs.d/elpa/org-9.4.4/)) to ask for a note and also
for a specific property when moving a state to WAIT. For that I use

(setq
  org-todo-keywords '((sequence "NEXT" "TODO" "WAIT(w@)" "|"
"DONE(d!)" "NODO(n@)"))
  org-log-into-drawer t
)

(defun flo/org-state-change()
  (when (string= org-state "WAIT")
(org-set-property "DELEGATED_TO" (read-string "Delegate To: "

(setq org-after-todo-state-change-hook 'flo/org-state-change)

However, I suspect the state-change-hook and the note when leaving
WAIT state conflict:

Error in post-command-hook (org-add-log-note): (error "Can’t expand
minibuffer to full frame")

resulting in that I am only asked to set the property, note the note.

What can i do about it? I don't really care in which order I enter the
two note / property.

Thanks,
Florian


I seem to recall having a similar conflict.  In my case, I realized that
the calling script "kept going" instead of waiting for the note entry to
be completed.  Therefore, try and make sure that org-log-into-drawer
gets called "last."  I am pretty sure this will require digging into Org
internals to see in what order things go.

Sorry if that's vague, it's been a while since I dealt with this.  And
it may or may not even actually be your problem.

Cheers,
TRS-80



Symolic link messes up org-attach?

2021-02-22 Thread Henrik Frisk
Hi,

I have migrated from a OSX based system to a linux/debian system. I have
all my main org files in a directory ~/org and in OSX this was a symbolic
link to ~/a-hard-disk/org (it may have been an alias, ot sure). In Ubuntu,
however, I have lots of trouble with org-attach: I attach a file using say
copy and when I call C-c C-a o there are no attachments. Sometimes it works
but next time I open the file there are no attachments. I experienced
similar issues with links:

[[file:./img/myimage.png]]

was not found but a qualified path worked.

Could this be because of the symlink to my org directory? Is there a better
way to do it?

Best,
Henrik


RE: state of the art in org-mode tables e.g. join, etc

2021-02-22 Thread Cook, Malcolm
Greg,

Of course, I’m not surprised by the results of your efforts.  Nice!

I myself don’t prefer the tidyverse, mainly except for ggplot, and instead find 
myself reaching for sqldf or data.tables where such benefit is needed.

YMMV,

Malcolm

From: Greg Minshall 
Sent: Monday, February 22, 2021 02:13
To: Cook, Malcolm 
Cc: John Kitchin ; Tim Cross ; 
org-mode-email 
Subject: Re: state of the art in org-mode tables e.g. join, etc

ATTENTION: This email came from an external source. Do not open attachments or 
click on links from unknown senders or unexpected emails.


Malcolm,

> Checkout what R sqldf package makes easy:

very nice!

Greg

ps -- (feeling a challenge... :) for base R, dplyr::inner_join, the
following seem to work (i apologize that i don't know how people embed
org-frags in e-mail, or how important that format might be?)

#+NAME: original
| Day | Color | Level | Quantity |
|---+---+---+--|
| Monday | Red | 30 | 11 |
| Monday | Blue | 25 | 3 |
| Tuesday | Red | 51 | 12 |
| Tuesday | Red | 45 | 15 |
| Tuesday | Blue | 33 | 18 |
| Wednesday | Red | 27 | 23 |
| Wednesday | Blue | 12 | 16 |
| Wednesday | Blue | 15 | 15 |
| Thursday | Red | 39 | 24 |
| Thursday | Red | 41 | 29 |
| Thursday | Red | 49 | 30 |
| Friday | Blue | 7 | 5 |
| Friday | Blue | 6 | 8 |
| Friday | Blue | 11 | 9 |

#+PROPERTY: header-args:R :session *R*
#+begin_src R :results none
library(dplyr)
#+end_src

#+begin_src R :var original=original :colnames yes
as.data.frame(table(Color=original$Color))
#+end_src

#+RESULTS:
| Color | Freq |
|---+--|
| Blue | 7 |
| Red | 7 |



*** join example

Example from https://github.com/tbanel/orgtbljoin

#+name: nutrition
| type | Fiber | Sugar | Protein | Carb |
|--+---+---+-+--|
| eggplant | 2.5 | 3.2 | 0.8 | 8.6 |
| tomatoe | 0.6 | 2.1 | 0.8 | 3.4 |
| onion | 1.3 | 4.4 | 1.3 | 9.0 |
| egg | 0 | 18.3 | 31.9 | 18.3 |
| rice | 0.2 | 0 | 1.5 | 16.0 |
| bread | 0.7 | 0.7 | 3.3 | 16.0 |
| orange | 3.1 | 11.9 | 1.3 | 17.6 |
| banana | 2.1 | 9.9 | 0.9 | 18.5 |
| tofu | 0.7 | 0.5 | 6.6 | 1.4 |
| nut | 2.6 | 1.3 | 4.9 | 7.2 |
| corn | 4.7 | 1.8 | 2.8 | 21.3 |


#+name: recipe
| type | quty |
|--+--|
| onion | 70 |
| tomatoe | 120 |
| eggplant | 300 |
| tofu | 100 |


#+begin_src R :var recipe=recipe :var nutrition=nutrition :colnames yes
dplyr::inner_join(nutrition, recipe)
#+end_src

#+RESULTS:
| type | Fiber | Sugar | Protein | Carb | quty |
|--+---+---+-+--+--|
| eggplant | 2.5 | 3.2 | 0.8 | 8.6 | 300 |
| tomatoe | 0.6 | 2.1 | 0.8 | 3.4 | 120 |
| onion | 1.3 | 4.4 | 1.3 | 9 | 70 |
| tofu | 0.7 | 0.5 | 6.6 | 1.4 | 100 |


error "Can’t expand minibuffer to full frame"

2021-02-22 Thread Florian Lindner

Hello,
I try to configure my org mode (Org mode version  ( @ 
/lhome/lindnfl/.emacs.d/elpa/org-9.4.4/)) to ask for a note and also for a 
specific property when moving a state to WAIT. For that I use

(setq
  org-todo-keywords '((sequence "NEXT" "TODO" "WAIT(w@)" "|" "DONE(d!)" 
"NODO(n@)"))
  org-log-into-drawer t
)

(defun flo/org-state-change()
  (when (string= org-state "WAIT")
    (org-set-property "DELEGATED_TO" (read-string "Delegate To: "

(setq org-after-todo-state-change-hook 'flo/org-state-change)


However, I suspect the state-change-hook and the note when leaving WAIT state 
conflict:

Error in post-command-hook (org-add-log-note): (error "Can’t expand minibuffer 
to full frame")

resulting in that I am only asked to set the property, note the note.

What can i do about it? I don't really care in which order I enter the two note 
/ property.

Thanks,
Florian
 


Re: 'false' list item

2021-02-22 Thread Eric S Fraga
Hello all,

> YMMV depending on your needs and habits, but another workaround for this
> problem would be to use visual-line-mode instead of filling paragraphs.

as Kyle has already mentioned, this is a well known limitation of org
and no reasonable solution has been found in the past.  I partly moved
to visual-line-mode with org-indent-mode for this reason and this
combination works very well for me.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.4-231-gf46925



Re: state of the art in org-mode tables e.g. join, etc

2021-02-22 Thread Derek Feichtinger
Hi John,

I invested time some years ago in preparing babel examples, and a lot of
the description went into using tables. The most detailed documents I
had for elisp and python.

In order to be productive, e.g. for producing all kinds of scientific
graphs, but also for doing the finances and planning for our scientific
computing section I ended up the same as you with mostly going to python
and leveraging Pandas. I think all of us end up using ":colnames no" as
the most convenient solution.

https://github.com/dfeich/org-babel-examples/blob/master/python3/python3-babel.org

(especially look at the Pandas section 10)

In that file I also tangle a python library "orgbabelhelper" that is
available in Conda and PyPi. I mainly use that to work with my tables.

Best regards
Derek

-- 
Paul Scherrer Institut
Dr. Derek Feichtinger   Phone:   +41 56 310 47 33
Group Head HPC and Emerging Technologies  Email: derek.feichtin...@psi.ch
Building/Room No. OHSA/D17
Forschungsstrasse 111
CH-5232 Villigen PSI 

On Sun, Feb 21 2021, John Kitchin  wrote:

> For fun, here is the sqlite equivalent of the Pandas example using the same
> tables as before
>
>
> ** aggregation example
>
> Examples from https://github.com/tbanel/orgaggregate
>
>
> #+NAME: original
> | Day   | Color | Level | Quantity |
> |---+---+---+--|
> | Monday| Red   |30 |   11 |
> | Monday| Blue  |25 |3 |
> | Tuesday   | Red   |51 |   12 |
> | Tuesday   | Red   |45 |   15 |
> | Tuesday   | Blue  |33 |   18 |
> | Wednesday | Red   |27 |   23 |
> | Wednesday | Blue  |12 |   16 |
> | Wednesday | Blue  |15 |   15 |
> | Thursday  | Red   |39 |   24 |
> | Thursday  | Red   |41 |   29 |
> | Thursday  | Red   |49 |   30 |
> | Friday| Blue  | 7 |5 |
> | Friday| Blue  | 6 |8 |
> | Friday| Blue  |11 |9 |
>
>
> #+begin_src sqlite :db ":memory:" :var orgtable=original :colnames yes
> drop table if exists testtable;
> create table testtable(Day str, Color str, Level int, Quantity int);
> .mode csv testtable
> .import $orgtable testtable
> select Color, count(*) from testtable group by Color;
> #+end_src
>
> #+RESULTS:
> | Color | count(*) |
> |---+--|
> | Blue  |7 |
> | Red   |7 |
>
> ** join example
>
> Example from https://github.com/tbanel/orgtbljoin
>
> #+name: nutrition
> | type | Fiber | Sugar | Protein | Carb |
> |--+---+---+-+--|
> | eggplant |   2.5 |   3.2 | 0.8 |  8.6 |
> | tomatoe  |   0.6 |   2.1 | 0.8 |  3.4 |
> | onion|   1.3 |   4.4 | 1.3 |  9.0 |
> | egg  | 0 |  18.3 |31.9 | 18.3 |
> | rice |   0.2 | 0 | 1.5 | 16.0 |
> | bread|   0.7 |   0.7 | 3.3 | 16.0 |
> | orange   |   3.1 |  11.9 | 1.3 | 17.6 |
> | banana   |   2.1 |   9.9 | 0.9 | 18.5 |
> | tofu |   0.7 |   0.5 | 6.6 |  1.4 |
> | nut  |   2.6 |   1.3 | 4.9 |  7.2 |
> | corn |   4.7 |   1.8 | 2.8 | 21.3 |
>
>
> #+name: recipe
> | type | quty |
> |--+--|
> | onion|   70 |
> | tomatoe  |  120 |
> | eggplant |  300 |
> | tofu |  100 |
>
>
> #+begin_src sqlite :db ":memory:" :var nut=nutrition rec=recipe :colnames
> yes
> drop table if exists nutrition;
> drop table if exists recipe;
> create table nutrition(type str, Fiber float, Sugar float, Protein float,
> Carb float);
> create table recipe(type str, quty int);
>
> .mode csv nutrition
> .import $nut nutrition
>
> .mode csv recipe
> .import $rec recipe
>
> select * from recipe, nutrition where recipe.type=nutrition.type;
> #+end_src
>
> #+RESULTS:
> | type | quty | type | Fiber | Sugar | Protein | Carb |
> |--+--+--+---+---+-+--|
> | onion|   70 | onion|   1.3 |   4.4 | 1.3 |  9.0 |
> | tomatoe  |  120 | tomatoe  |   0.6 |   2.1 | 0.8 |  3.4 |
> | eggplant |  300 | eggplant |   2.5 |   3.2 | 0.8 |  8.6 |
> | tofu |  100 | tofu |   0.7 |   0.5 | 6.6 |  1.4 |
>
>
> John
>
> ---
> Professor John Kitchin
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> http://kitchingroup.cheme.cmu.edu
>
>
>
> On Sun, Feb 21, 2021 at 10:03 AM John Kitchin 
> wrote:
>
>> Thanks Tim and Greg. I had mostly come to the same conclusions that it is
>> probably best to outsource this. I worked out some examples from
>> the orgtbljoin and orgaggregate packages with Pandas below, in case anyone
>> is interested in seeing how it works. A key point is using the ":colnames
>> no" header args to get the column names for Pandas. It seems like a pretty
>> good approach.
>>
>> * org-mode tables with Pandas
>> ** Aggregating from a table
>>
>> Examples from https://github.com/tbanel/orgaggregate
>>
>>
>> #+NAME: original
>> | Day   | 

Re: state of the art in org-mode tables e.g. join, etc

2021-02-22 Thread Greg Minshall
Malcolm,

> Checkout what R sqldf package makes easy:

very nice!

Greg

ps -- (feeling a challenge... :) for base R, dplyr::inner_join, the
following seem to work (i apologize that i don't know how people embed
org-frags in e-mail, or how important that format might be?)

 #+NAME: original
 | Day   | Color | Level | Quantity |
 |---+---+---+--|
 | Monday| Red   |30 |   11 |
 | Monday| Blue  |25 |3 |
 | Tuesday   | Red   |51 |   12 |
 | Tuesday   | Red   |45 |   15 |
 | Tuesday   | Blue  |33 |   18 |
 | Wednesday | Red   |27 |   23 |
 | Wednesday | Blue  |12 |   16 |
 | Wednesday | Blue  |15 |   15 |
 | Thursday  | Red   |39 |   24 |
 | Thursday  | Red   |41 |   29 |
 | Thursday  | Red   |49 |   30 |
 | Friday| Blue  | 7 |5 |
 | Friday| Blue  | 6 |8 |
 | Friday| Blue  |11 |9 |

 #+PROPERTY: header-args:R  :session *R*
 #+begin_src R :results none
   library(dplyr)
 #+end_src

 #+begin_src R :var original=original :colnames yes
   as.data.frame(table(Color=original$Color))
 #+end_src

 #+RESULTS:
 | Color | Freq |
 |---+--|
 | Blue  |7 |
 | Red   |7 |



*** join example

 Example from https://github.com/tbanel/orgtbljoin

 #+name: nutrition
 | type | Fiber | Sugar | Protein | Carb |
 |--+---+---+-+--|
 | eggplant |   2.5 |   3.2 | 0.8 |  8.6 |
 | tomatoe  |   0.6 |   2.1 | 0.8 |  3.4 |
 | onion|   1.3 |   4.4 | 1.3 |  9.0 |
 | egg  | 0 |  18.3 |31.9 | 18.3 |
 | rice |   0.2 | 0 | 1.5 | 16.0 |
 | bread|   0.7 |   0.7 | 3.3 | 16.0 |
 | orange   |   3.1 |  11.9 | 1.3 | 17.6 |
 | banana   |   2.1 |   9.9 | 0.9 | 18.5 |
 | tofu |   0.7 |   0.5 | 6.6 |  1.4 |
 | nut  |   2.6 |   1.3 | 4.9 |  7.2 |
 | corn |   4.7 |   1.8 | 2.8 | 21.3 |


 #+name: recipe
 | type | quty |
 |--+--|
 | onion|   70 |
 | tomatoe  |  120 |
 | eggplant |  300 |
 | tofu |  100 |


 #+begin_src R :var recipe=recipe :var nutrition=nutrition :colnames yes
   dplyr::inner_join(nutrition, recipe)
 #+end_src

 #+RESULTS:
 | type | Fiber | Sugar | Protein | Carb | quty |
 |--+---+---+-+--+--|
 | eggplant |   2.5 |   3.2 | 0.8 |  8.6 |  300 |
 | tomatoe  |   0.6 |   2.1 | 0.8 |  3.4 |  120 |
 | onion|   1.3 |   4.4 | 1.3 |9 |   70 |
 | tofu |   0.7 |   0.5 | 6.6 |  1.4 |  100 |