From: Dan Davison <davison@stats.ox.ac.uk>
To: Graham Smith <myotisone@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [babel] multiple result outputs from function
Date: Tue, 16 Mar 2010 14:35:08 -0400 [thread overview]
Message-ID: <87mxy8nmhv.fsf@stats.ox.ac.uk> (raw)
In-Reply-To: <2c75873c1003161126r36c5e2c0kfa3f3540bf9ec7cf@mail.gmail.com> (Graham Smith's message of "Tue, 16 Mar 2010 18:26:44 +0000")
Graham Smith <myotisone@gmail.com> writes:
> Below is a function that I am trying to run in orgmode/babel.
>
> It seems to run OK, but instead of printing out three values, its only
> printing the final result.
>
> Once again, i would appreciate some help with what I am missing.
Hi Graham,
Use ':results output' to get the printed output. The default mode
is ':results value' which returns the value of the last expression in
the block.
#+srcname: CI_function
#+begin_src R :session daf
summary.ci<-function(x){
print ("value 1")
print ("value 2")
print ("value 3")
}
#+end_src
#+begin_src R :session daf :results output
summary.ci()
#+end_src
#+results:
: [1] "value 1"
: [1] "value 2"
: [1] "value 3"
#+begin_src R :session daf
summary.ci()
#+end_src
#+results:
: value 3
Dan
>
> Thanks,
>
> Graham
>
>
> #+srcname: CI_function
> #+begin_src R :session daf
> summary.ci<-function(x){
> xbar<-mean(x)
> sigma<-sd(x)
> n<-length(x)
> sem<-sigma/sqrt(n)
> lower.ci<-xbar+sem*qnorm(0.025)
> upper.ci<-xbar+sem*qnorm(0.975)
> print (xbar)
> print (lower.ci)
> print (upper.ci)
> }
> #+end_src
>
> #+srcname: SumFlowering2005
> #+begin_src R :session daf
> summary.ci(daf$Flower[daf$YEAR=="2005"])
> #+end_src
>
> #+results: SumFlowering2005
> : 1.97860201016947
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
next prev parent reply other threads:[~2010-03-16 18:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-16 18:26 [babel] multiple result outputs from function Graham Smith
2010-03-16 18:35 ` Dan Davison [this message]
2010-03-16 18:43 ` Graham Smith
2010-03-16 18:39 ` Erik Iverson
2010-03-16 18:53 ` Graham Smith
2010-03-16 19:26 ` Dan Davison
2010-03-16 19:38 ` Graham Smith
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mxy8nmhv.fsf@stats.ox.ac.uk \
--to=davison@stats.ox.ac.uk \
--cc=emacs-orgmode@gnu.org \
--cc=myotisone@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).