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:
I like the result except the "X.Value." and "X.Type." to label each axis.
- Is what I'm doing the standard way to pass a table with column names to R?
- Is the R script written appropriately?
- 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?