0

I have an org file with this content:

#+name: my-table
| *Type*  | *Value* |
|---------+---------|
| Web     |     744 |
| Checks  |     520 |
| Cash    |     105 |
|---------+---------|
| *Total* |    1369 |
#+TBLFM: @5$2=vsum(@I..@II)

I would like to add an R script to draw a bar chart of the result so I tried:

#+NAME: barchart
#+begin_src R :results output graphics file :colnames yes :session :exports none :var data=my-table[0:-2] :file my-table.png
library(tidyverse)
ggplot(data = data) + geom_bar(mapping = aes(x = X.Type., y = X.Value.), stat = "identity")
#+end_src

This results in:

enter image description here

I like the result except the "X.Value." and "X.Type." to label each axis.

  1. Is what I'm doing the standard way to pass a table with column names to R?
  2. Is the R script written appropriately?
  3. Is there a way to use my column names (i.e., "Type" and "Value") instead of "X.Value." and "X.Type."? Alternatively, can I change the axis label in R?
2
  • These are R questions, much more than emacs/Org mode questions. An R expert might stumble on it here, but you might have better luck asking it on SO. – NickD Feb 14 at 22:31
  • yes and now. The way org-mode passes columns names or not to R is very specific to Org I guess. But I will search R documentation to workaround the issue if no one answers here. – Damien Cassou Feb 15 at 7:54

Your Answer

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

Browse other questions tagged or ask your own question.