If you open the .org file I attached, there are #+ header lines at the start that get inserted as standard templates, if you will.
The line starting with a single '*' is a top-level header.
Then the block starting #+NAME: and ending #+END_SRC is a code block with associated headers. BEGIN_SRC R says it's an R code block, and the three lines inside are thus pure R. The print() is R's command.
Hmm. One could define Stan as
another supported language and then write Stan code directly into an Org code block. It wouldn't be the first compiled language; you can already see C, C++, Fortran, ..... I don't know if it's worth the effort, though.
I think this is the problem.
http://orgmode.org/manual/Results-of-evaluation.html suggests that .Last.value may not be being set as org-mode expects;
http://stat.ethz.ch/R-manual/R-devel/library/base/html/Last.value.html tells what that R variable is.
If, using RStudio, I print something in R and then print a stanfit object in R, entering .Last.value after each, I get different results from the two print() commands:
> print('abc')
[1] "abc"
> .Last.value
[1] "abc"
> print(stanobject)
Inference for Stan model: Model01.
4 chains, each with iter=250; warmup=125; thin=1;
post-warmup draws per chain=125, total post-warmup draws=500.
mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat
alpha -1.08 0.02 0.12 -1.34 -1.14 -1.08 -1.01 -0.88 26 1.14
beta 3.59 0.03 0.16 3.31 3.49 3.58 3.67 3.93 26 1.14
sigma 0.24 0.00 0.01 0.22 0.23 0.24 0.25 0.26 233 1.00
lp__ 229.47 0.16 1.34 226.10 228.98 229.82 230.46 230.91 72 1.05
Samples were drawn using NUTS(diag_e) at Fri May 15 15:22:15 2015.
For each parameter, n_eff is a crude measure of effective sample size,
and Rhat is the potential scale reduction factor on split chains (at
convergence, Rhat=1).
> .Last.value
NULLIs it possible that print.stanfit simply forgot to set .Last.value? Is there a reason it can't be set?
Thanks,
Bill
PS: My current workaround is to split the print() statement into a second code block. I export nothing from the stan() command block, and I export everything from the print() block. If print.stanfit() can be made to set .Last.value, that would be better.
.