* [Babel] Header arguments
@ 2011-05-14 2:56 Thomas S. Dye
2011-05-14 4:04 ` Nick Dokos
2011-05-14 14:05 ` Eric Schulte
0 siblings, 2 replies; 3+ messages in thread
From: Thomas S. Dye @ 2011-05-14 2:56 UTC (permalink / raw)
To: emacs-orgmode
Aloha all,
I have a little function that graphs two 14C dates (below). The data
are held in tables produced by a software package that I access on the
web. I read these into Org-mode and give them a #+tblname:, as shown
below. I'd like to have one function that will graph any number of tables
but I don't know how to package up the table references and get them
inside the function. If I put them in a table, they end up as strings
inside the function.
I suspect I'm being thick about this. Can someone give me a pointer to
how this might be done?
All the best,
Tom
#+tblname: theta-one-no-rat
| cal BP | Posterior probability |
|--------+-----------------------|
| -1520 | 1.8353001633417145E-5 |
...
**** Two dates
#+srcname: two-dated-events
#+header: :file ~/org/tsdye/two-dates.pdf
#+header: :var xlab="theta_1"
#+header: :var x=theta-one-no-rat
#+header: :var ylab="theta_4"
#+header: :var y=theta-four-no-rat
#+header: :width 6 :height 4 :results output graphics
#+begin_src R
library(ggplot2)
res <- data.frame(cal.BP=numeric(0),Posterior.probability=numeric(0),label=character(0))
res <- rbind(res,cbind(x,label=rep(xlab,dim(x)[1])))
res <- rbind(res,cbind(y,label=rep(ylab,dim(y)[1])))
theme_set(theme_bw(base_size=11))
g <- ggplot(res, aes(x=1950 + cal.BP, y=Posterior.probability))
g + geom_bar(stat='identity') + xlab("Year AD") +
ylab("Probability") + facet_wrap(~ label)
#+end_src
--
Thomas S. Dye
http://www.tsdye.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Babel] Header arguments
2011-05-14 2:56 [Babel] Header arguments Thomas S. Dye
@ 2011-05-14 4:04 ` Nick Dokos
2011-05-14 14:05 ` Eric Schulte
1 sibling, 0 replies; 3+ messages in thread
From: Nick Dokos @ 2011-05-14 4:04 UTC (permalink / raw)
To: Thomas S. Dye; +Cc: nicholas.dokos, emacs-orgmode
Thomas S. Dye <tsd@tsdye.com> wrote:
> Aloha all,
>
> I have a little function that graphs two 14C dates (below). The data
> are held in tables produced by a software package that I access on the
> web. I read these into Org-mode and give them a #+tblname:, as shown
> below. I'd like to have one function that will graph any number of tables
> but I don't know how to package up the table references and get them
> inside the function. If I put them in a table, they end up as strings
> inside the function.
>
> I suspect I'm being thick about this. Can someone give me a pointer to
> how this might be done?
>
> All the best,
> Tom
>
> #+tblname: theta-one-no-rat
> | cal BP | Posterior probability |
> |--------+-----------------------|
> | -1520 | 1.8353001633417145E-5 |
> ...
>
>
> **** Two dates
> #+srcname: two-dated-events
> #+header: :file ~/org/tsdye/two-dates.pdf
> #+header: :var xlab="theta_1"
> #+header: :var x=theta-one-no-rat
> #+header: :var ylab="theta_4"
> #+header: :var y=theta-four-no-rat
> #+header: :width 6 :height 4 :results output graphics
> #+begin_src R
> library(ggplot2)
> res <- data.frame(cal.BP=numeric(0),Posterior.probability=numeric(0),label=character(0))
> res <- rbind(res,cbind(x,label=rep(xlab,dim(x)[1])))
> res <- rbind(res,cbind(y,label=rep(ylab,dim(y)[1])))
> theme_set(theme_bw(base_size=11))
> g <- ggplot(res, aes(x=1950 + cal.BP, y=Posterior.probability))
> g + geom_bar(stat='identity') + xlab("Year AD") +
> ylab("Probability") + facet_wrap(~ label)
> #+end_src
>
In a similar situation, I was able to do it as follows:
,----
| #+srcname: org2cw
| #+begin_src python :results output :exports none
| s = ""
| for row in table:
| ...do something with row and modify s...
| print s
|
| #+end_src
|
| #+call: org2cw(table=support.obs) :file support.obs.cwiki
|
| #+call: org2cw(table=support) :file support.cwiki
|
`----
Each #+call is given a different table as an argument:
,----
| #+tblname: support.obs
| <table elided>
|
| #+tblname: support
| <table elided>
`----
Note the role of ``table'' as the parameter name in the #+call:s
and its use as a variable in the source block.
HTH,
Nick
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Babel] Header arguments
2011-05-14 2:56 [Babel] Header arguments Thomas S. Dye
2011-05-14 4:04 ` Nick Dokos
@ 2011-05-14 14:05 ` Eric Schulte
1 sibling, 0 replies; 3+ messages in thread
From: Eric Schulte @ 2011-05-14 14:05 UTC (permalink / raw)
To: Thomas S. Dye; +Cc: emacs-orgmode
tsd@tsdye.com (Thomas S. Dye) writes:
> Aloha all,
>
> I have a little function that graphs two 14C dates (below). The data
> are held in tables produced by a software package that I access on the
> web. I read these into Org-mode and give them a #+tblname:, as shown
> below. I'd like to have one function that will graph any number of tables
> but I don't know how to package up the table references and get them
> inside the function. If I put them in a table, they end up as strings
> inside the function.
>
Hi Tom,
The following example might work, it uses an emacs-lisp code block to
wrap any number of tables into a single list of tables which could then
be passed to R.
#+data: table-names
- first-table
- second-table
- third-table
#+data: first-table
| a | 1 |
| b | 2 |
#+data: second-table
| c | 3 |
| d | 4 |
#+data: third-table
| e | 5 |
| f | 6 |
#+begin_src emacs-lisp :var table-names=table-names
(mapcar #'org-babel-ref-resolve table-names)
#+end_src
#+results:
| (a 1) | (b 2) |
| (c 3) | (d 4) |
| (e 5) | (f 6) |
--
Eric Schulte
http://cs.unm.edu/~eschulte/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-05-14 14:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-14 2:56 [Babel] Header arguments Thomas S. Dye
2011-05-14 4:04 ` Nick Dokos
2011-05-14 14:05 ` Eric Schulte
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).