From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastien Vauban Subject: Re: Can't execute the introductory code: take table as input to produce mean Date: Tue, 05 Aug 2014 11:52:48 +0200 Message-ID: <86zjfj2rgv.fsf@somewhere.org> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: emacs-orgmode-mXXj517/zsQ@public.gmane.org Hello jenia, > I want to learn babel-mode so I'm going through > http://orgmode.org/worg/org-contrib/babel/intro.html#source-code-blocks-org. > > I'm trying to execute the basic tutorial's script and for some reason can't > do it. > > I'm suppose to feed a table as input to a function. This is the table: > > #+name: tbl-example-data() > #+begin_src R > runif(n=5, min=0, max=1) > #+end_src > > #+RESULTS: tbl-example-data > | 0.607781215803698 | > | 0.157157169422135 | > | 0.675619817571715 | > | 0.0488600700628012 | > | 0.998780139256269 | > > The next function is the function to be executed: > > #+name: R-mean(x) > #+begin_src R > mean(x) > #+end_src > > When I try to run it by pressing `C-c C-c` > I get `variable "x" in block "R-mean" must be assigned a default value`. > > How do I run the function R-mean using the vlaues from tbl-example-data? Add a variable to your code block: #+name: R-mean(x) #+begin_src R :var x=tbl-example-data mean(x) #+end_src Best regards, Seb -- Sebastien Vauban