* Can't execute the introductory code: take table as input to produce mean
@ 2014-08-05 6:48 jenia mtl
2014-08-05 9:52 ` Sebastien Vauban
0 siblings, 1 reply; 4+ messages in thread
From: jenia mtl @ 2014-08-05 6:48 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1056 bytes --]
Hello:
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`.
I tried to explicitly run the function R-mean(x) like so.
#+call: R-mean(tbl-example-data)
Unfortunately I get
Reference 'R-mean' not found in this buffer
How do I run the function R-mean using the vlaues from tbl-example-data?
Thanks in advance.
Jenia
[-- Attachment #2: Type: text/html, Size: 1443 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Can't execute the introductory code: take table as input to produce mean
2014-08-05 6:48 Can't execute the introductory code: take table as input to produce mean jenia mtl
@ 2014-08-05 9:52 ` Sebastien Vauban
0 siblings, 0 replies; 4+ messages in thread
From: Sebastien Vauban @ 2014-08-05 9:52 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Can't execute the introductory code: take table as input to produce mean
@ 2014-08-06 6:08 jenia.ivlev
2014-08-06 14:14 ` Sebastien Vauban
0 siblings, 1 reply; 4+ messages in thread
From: jenia.ivlev @ 2014-08-06 6:08 UTC (permalink / raw)
To: public-emacs-orgmode-mXXj517/zsQ
Its the first time I use this type of mail system. I connected here
using gmane and gnus. I;m not sure how to answer the thread "Can't
execute the introductory code: take table as input to produce mean".
So i'll just try to answer the best way I can who means I'll answer to:
emacs-orgmode-mXXj517/zsQ@public.gmane.org.
Thanks Sebastien. Tell me though please, how do I define R-mean(x) to
take any x? How do I run R-mean in the following form:
R-mean(my-table1), R-mean(my-table2)...
Cause here, it seems that R-mean is defined with the variable "x"
hard-wired to a specific value, namely x=tbl-example-data.
So again, how do I call R-mean with x=tbl-example-data2 lets say
(without redefining R-mean)?
Thanks in advance.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Can't execute the introductory code: take table as input to produce mean
2014-08-06 6:08 jenia.ivlev
@ 2014-08-06 14:14 ` Sebastien Vauban
0 siblings, 0 replies; 4+ messages in thread
From: Sebastien Vauban @ 2014-08-06 14:14 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
jenia.ivlev wrote:
> Its the first time I use this type of mail system. I connected here
> using gmane and gnus. I;m not sure how to answer the thread "Can't
> execute the introductory code: take table as input to produce mean".
> So i'll just try to answer the best way I can who means I'll answer to:
> emacs-orgmode-0jIIvIziipk@public.gmane.org
>
> Thanks Sebastien. Tell me though please, how do I define R-mean(x) to
> take any x? How do I run R-mean in the following form:
> R-mean(my-table1), R-mean(my-table2)...
> Cause here, it seems that R-mean is defined with the variable "x"
> hard-wired to a specific value, namely x=tbl-example-data.
Adding `:var x=something' serves 2 purposes:
- Defining the `x' parameter (to the code block)
- Setting its default value
> So again, how do I call R-mean with x=tbl-example-data2 lets say
> (without redefining R-mean)?
#+call: R-mean(x=tbl-example-data2)
Best regards,
Seb
--
Sebastien Vauban
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-08-06 14:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-05 6:48 Can't execute the introductory code: take table as input to produce mean jenia mtl
2014-08-05 9:52 ` Sebastien Vauban
-- strict thread matches above, loose matches on Subject: below --
2014-08-06 6:08 jenia.ivlev
2014-08-06 14:14 ` Sebastien Vauban
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).