0

I'm trying to draw a pie chart from an orgmode table. Let's keep it as simple as possible.

#+TBLNAME:kuchen
| 100 | ABC |
|   3 | DEF |
| 123 | XYZ |


#+name: pie-chart (kuchen = kuchen)
#+begin_src R :file pie.png 
pie(kuchen[,1], labels = kuchen[,2])
#+end_src

But the resulting pie.png is 0 Bytes, empty.

Error message:

Fehler in pie(kuchen[, 1], labels = kuchen[, 2]) : 
  Objekt 'kuchen' nicht gefunden
Ruft auf: <Anonymous> -> <Anonymous> -> pie
Ausführung angehalten

Translation: error in pie, object 'kuchen' not found, calls -> -> pie, execution halted

I found this guide: https://orgmode.org/worg/org-contrib/babel/intro.html#meta-programming-language . But if I simply copy the example given there into emacs and export it to html, the (in the case of the guide:) dirs.png is 0 Byte = empty as well.

At a first glance, this website seemed very helpful as well:

https://orgmode.org/worg/org-tutorials/org-R/org-R.html

But the given »actions« on a »intable« don't include any »pie« command.

Any ideas how to get a pie chart from an orgmode table?

If the table needed a third column with percentage, no problem. Any solution welcome.

  • The variable definition has to be added as a header on the #+ begin_src line, not on the name line, although that's probably just the first problem: I could not make this work (but I know next to nothing about R). – NickD Oct 28 '19 at 15:45
3

As mentioned in my comment, you need to pass the variable as a :var header on the #+begin_src line, not on the #+name: line. But you also need to specify that the results be output to a graphics file. The following worked for me:

#+TBLNAME:kuchen
| 100 | ABC |
|   3 | DEF |
| 123 | XYZ |


#+name: piechart
#+begin_src R :results file graphics :file pie.png :var kuchen=kuchen 
pie(kuchen[,1], labels = kuchen[,2])
#+end_src

#+RESULTS: piechart
[[file:pie.png]]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.