Re: [Orgmode] org-babel-R and windows ?

2010-01-12 Thread Manish
On Tue, Jan 12, 2010 at 11:13 PM, Dan Davison wrote:
[snip:  snipped (43 lines)]
>
> The org-babel default is to invoke R as an external shell command, and I
> think this is what is causing the problem. It requires that the emacs
> function shell-command can use the string "R" to invoke an R process,
> i.e. the R installation and the shell path must be such that this is the
> case.
>
> Seeing as you have ESS installed, how about using session-based
> evaluation? This means that org-babel uses an interactive R session
> running under the control of ESS. In general it is a better way to work
> with R in org-babel. It is described in the section "Session-based
> Evaluation" in
>
> http://orgmode.org/worg/org-contrib/babel/intro.php
>
> and also in the reference manual:
>
> http://orgmode.org/worg/org-contrib/babel/reference.php#header-argument-session
>
> basically you just set the :session header argument, e.g.
>
> #+srcname:trial
> #+begin_src R :session org-babel-R-session
>   c(4,5,6,7,8,9)
> #+end_src
>

Thanks for the advice regarding using sessions.  It works now.  But I
have something interesting to report.

With following test org file, evaluation of R block fails to produce
desired results.  If the lines with "require" are removed, the
evaluation works fine.  R session buffer contents are pasted below as
well just in case they are of any help.

--8<---cut here---start->8---
* Test

Here's how to set it up.

(require 'org_babel_init)
(require 'org_babel_R)
(org_babel_load_library_of_babel)

#+srcname: strings
#+begin_src R :colnames t :session org-babel-R-strings
  t(sort(table(tolower(scan("~/personal/test-org-babel.org", what="",
na.strings="|"))), decreasing=TRUE)[1:10])
#+end_src

#+results: strings
--8<---cut here---end--->8---


--8<---cut here---start->8---
R version 2.10.0 (2009-10-26)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> options(chmhelp = FALSE)
> options(STERM='iESS', editor='gnuclient.exe')
>
t(sort(table(tolower(scan("~/personal/test-org-babel.org", what="",
na.strings="|"))), decreasing=TRUE)[1:10])
write.table(.Last.value, file="d:/home/zms/tmp/org-babel-R1752nPK",
sep="\t", na="nil",row.names=FALSE, col.names=TRUE, quote=FALSE)
'org_babel_R_eoe'

> t(sort(table(tolower(scan("~/personal/test-org-babel.org", what="", 
> na.strings="|"))), decreasing=TRUE)[1:10])
Read 27 items

   strings #+begin_src #+end_src #+results: #+srcname:
  [1,]   2   1 1  1  1

   (org_babel_load_library_of_babel) (require * :colnames :session
  [1,] 11 1 11
> write.table(.Last.value, file="d:/home/zms/tmp/org-babel-R1752nPK", sep="\t", 
> na="nil",row.names=FALSE, col.names=TRUE, quote=FALSE)
> 'org_babel_R_eoe'
[1] "org_babel_R_eoe"
>
--8<---cut here---end--->8---

Thank you
-- 
Manish


___
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


Re: [Orgmode] org-babel-R and windows ?

2010-01-12 Thread Eric Schulte
Dan Davison  writes:

[...]

>
> The org-babel default is to invoke R as an external shell command, and I
> think this is what is causing the problem. It requires that the emacs
> function shell-command can use the string "R" to invoke an R process,
> i.e. the R installation and the shell path must be such that this is the
> case.
>

If the "R" command turns out to be the culprit it would be an easy fix
to make the command used to run R externally a user-defined variable.

 -- Eric


___
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


Re: [Orgmode] org-babel-R and windows ?

2010-01-12 Thread Dan Davison
"d.tchin"  writes:

> I need help to be able to use org-babel functionality. 
> I use emacs 22.3.1 in windows XP and org-mode 6.34.
>
> I have the following instructions in .emacs
>
> (require 'org-install)
> (require 'org-plot)
> (require 'org-babel-init)  
> (require 'org-babel-R) ;; requires R and ess-mode
> (require 'org-babel-python);; requires python, and python-mode
> (require 'org-babel-ditaa)
>
> ESS module is loaded before :
>
> (load "~/emacs/emacs-22.3/site-lisp/ess-5.7.1/lisp/ess-site")
>
>
> I don't manage to get any output with R Software. 
>
> Below you will find test I have done :
>
> #+srcname:trial
> #+begin_src sh
>   echo output
> #+end_src
>
> #+results: trial
> : output
>
> #+srcname:trial
> #+begin_src R
>   c(4,5,6,7,8,9)
> #+end_src
>
>
> I manage to have shell output, but when I tried R procedure,
> I have the following output in *Messages* buffer
>
> executing R source code block...
> Syntaxe du nom de fichier, de répertoire ou de volume incorrecte.
> Source block produced no output

The org-babel default is to invoke R as an external shell command, and I
think this is what is causing the problem. It requires that the emacs
function shell-command can use the string "R" to invoke an R process,
i.e. the R installation and the shell path must be such that this is the
case.

Seeing as you have ESS installed, how about using session-based
evaluation? This means that org-babel uses an interactive R session
running under the control of ESS. In general it is a better way to work
with R in org-babel. It is described in the section "Session-based
Evaluation" in

http://orgmode.org/worg/org-contrib/babel/intro.php

and also in the reference manual:

http://orgmode.org/worg/org-contrib/babel/reference.php#header-argument-session

basically you just set the :session header argument, e.g.

#+srcname:trial
#+begin_src R :session org-babel-R-session
   c(4,5,6,7,8,9)
#+end_src

Have a look here to see the different methods you can use to make this
the default (without having to explicitly set the header arg each time)

http://orgmode.org/worg/org-contrib/babel/reference.php#sec-3.1

Dan

>
> I have a look on temporary directory and I have the folllowing
> file :
>
> R-in-functional-results4452lyl
>
> Inside the following source code :
>
> main <- function ()
> {
>
> c(4,5,6,7,8,9)
>
>
> }
> write.table(main(), file="c:/Temp/emacs/tmp/R-out-functional-results4452y8r", 
> sep="\t", na="nil",row.names=FALSE, col.names=FALSE, quote=FALSE)
>
>
> The file  R-out-functional-results4452y8r exists but is empty.
> What I miss to make it work ?
>
> Regards
>
>
>
> ___
> 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


___
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


[Orgmode] org-babel-R and windows ?

2010-01-12 Thread d . tchin

I need help to be able to use org-babel functionality. 
I use emacs 22.3.1 in windows XP and org-mode 6.34.

I have the following instructions in .emacs

(require 'org-install)
(require 'org-plot)
(require 'org-babel-init)  
(require 'org-babel-R) ;; requires R and ess-mode
(require 'org-babel-python);; requires python, and python-mode
(require 'org-babel-ditaa)

ESS module is loaded before :

(load "~/emacs/emacs-22.3/site-lisp/ess-5.7.1/lisp/ess-site")


I don't manage to get any output with R Software. 

Below you will find test I have done :

#+srcname:trial
#+begin_src sh
  echo output
#+end_src

#+results: trial
: output

#+srcname:trial
#+begin_src R
  c(4,5,6,7,8,9)
#+end_src


I manage to have shell output, but when I tried R procedure,
I have the following output in *Messages* buffer

executing R source code block...
Syntaxe du nom de fichier, de répertoire ou de volume incorrecte.
Source block produced no output

I have a look on temporary directory and I have the folllowing
file :

R-in-functional-results4452lyl

Inside the following source code :

main <- function ()
{

c(4,5,6,7,8,9)


}
write.table(main(), file="c:/Temp/emacs/tmp/R-out-functional-results4452y8r", 
sep="\t", na="nil",row.names=FALSE, col.names=FALSE, quote=FALSE)


The file  R-out-functional-results4452y8r exists but is empty.
What I miss to make it work ?

Regards



___
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