Re: [R] User input when running R code in batch mode

2009-10-27 Thread Bernd Kreuss
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Kaushik Krishnan wrote:
 Is there any way to make R stop for the user to enter values when
 running in batch mode either by changing the way I invoke scan() or
 readLines() or by using any other function?

At least on linux this works:

be...@t40:~/r-test $ cat test.R

readline2 = function(prompt=){
cat(prompt)
readLines(stdin, 1)
}

print(readline2(enter a number: ))

be...@t40:~/r-test $ Rscript test.R
enter a number: 42
[1] 42


-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFK5xUSxT6R4jlFoh0RAkhTAKCB4qUjPlULL9vjUaLLxarTor2z1QCeNGHA
4B2VmkqtyEKMKKGUnt8sjiY=
=VYJs
-END PGP SIGNATURE-

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] API question (embedding R)

2009-10-26 Thread Bernd Kreuss
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello list,

i want to access R from a Pascal program. Basically i only need to be
able to

* start the engine / the interpreter (and keep it running)
* pass strings to it (R code) that should be parsed and executed
* get floats or vectors of floats into R and assign them to R variables
* read the contents of variables and get them back into my Pascal
program. (I dont need this for all possible data structures, just floats
and maybe vectors of floats would be sufficient)

At the moment i have something running that does exactly this via Python
and the rpy bindings, this works but is horribly complicated to install
because of all the needed dependencies. It works like this: the pascal
program loads the python interpreter (this API is extremely simple, i
can get floats and lists of floats in and out of python variables and
have it compile and execute python code), the pascal program then lets
python import the rpy bindings, put the data into python variables, from
there (by executing python code) move the data into R variables and then
finally execute R code (by executing python code that would call into R
to execute R code contained in a string literal). Getting the results
back goes a similar way.

Now i want to make this more straightforward, i need a way to directly
access the R interpreter just like i can already access the python
interpreter. Using the python interpreter from pascal is a child's play,
you really only need to import a handful of functions from the dll and
nothing else, you just call Py_Initialize() and then you can call
PyRun_SimpleString() as often as you want and thats basically all! No
need to convert the whole C header file to pascal, it all fits more or
less into 5 lines of pascal declarations.

I couldn't find an easy documentation of how i could achieve the same
thing with R: load the dll, import only a few needed functions (which
ones do i actually need?) and how to use them. Is there a minimal
example somewhere? What documents should I read? Maybe i missed
something important?

An example would actually be the most important thing, an example tells
more than thousand words.

Thanks in advance,
Bernd Kreuss
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFK5ikSxT6R4jlFoh0RAi8LAJwMiDRVWLZBZp2JYynpCtnS48r25gCgzrLF
s5hYB20RCr2RuxIPe8EW8ws=
=erKc
-END PGP SIGNATURE-

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to stop an R script when running JGR on a Linux/SuSE system

2009-08-02 Thread Bernd Kreuss
 This issue was addressed in a recent discussion [1].
 Liviu
 
 [1] 
 http://mailman.rz.uni-augsburg.de/pipermail/stats-rosuda-devel/2009q2/001106.html

I would like to add a few points to this list, some of them I personally
find even more annoying then some of them mentioned there:

- add the keyboard shortcuts shift-del and shift-ins for the
actions cut and paste as an alternative to ctrl-x and ctrl-c to
make it compliant with CUA and behave like virtually every other editor
in existance. (this is my most important concern, i use it all the time
when moving rearranging lines, being used to eclipse, SciTE, Kate, even
MS-Word, OpenOffice or notepad on windows, everytime i try to cut/paste
I already have a finger of the left hand on the shift-key (from
selecting the text) and it takes one or two seconds to realize that the
intended shortcut is missing and then move both hands to find the other
two keys on the keyboard)

- change the keyboard shortcuts for block-indent and block-dedent to the
more commonly used tab and shift-tab

- remove the restriction of a minimal window size for the console
window, allow the user to resize it as small as he wants.

- add a shortcut for run all, this is the only menu item without
shortcut. F5 would be a good choice as some other widely used
editor/shell combinations for other languages have similar functionality
on that key too (SciTE, IDLE, etc.), it seems to be some kind of
standard too.

Bernd

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to stop an R script when running JGR on a Linux/SuSE system

2009-08-02 Thread Bernd Kreuss
Bernd Kreuss wrote:

 I would like to add a few points to this list [...]

I would even make the changes on my own (i probably would already have
done it) and supply patches if i only could find any hint on how to
build JGR from sources. (where to place the source files, what command
to start the build process and where to copy which files after
successful built to test them)

So this is another point on my list: write a small howto on how to
participate in development.

Bernd

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to stop an R script when running JGR on a Linux/SuSE system

2009-08-02 Thread Bernd Kreuss
Liviu Andronic wrote:

 other missing dependencies), fetch the source archive [1] from CRAN,

I tried this already but this source archive only contains (besides some
C code for the starter) only one .jar file without any Java sources in
it, only .class files. Also i tried to check out the project directly
from svn but there is nothing java related at all. The source code must
be elsewhere.

I'm sure that JGR would make much faster progress if people were able to
just download a tar.gz with all relevant files in it together with a
readme.txt and a makefile or the java equivalent of it. If something
like this already exists it would be nice to put a link to it directly
on the JGR homepage, I couldn't find anything.

Bernd

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to stop an R script when running JGR on a Linux/SuSE system

2009-08-01 Thread Bernd Kreuss
mau...@alice.it wrote:

 I wonder whether there is a more gentle way to stop an R script running on 
 top of JGR aother than ... unplugging the power cord.

there must be a bug in JGR on Lunux. Clicking the stop button should
stop the script, clicking it here on my linux machine will immediately
crash R together with JGR altogether. Unfortunately JGR still seems to
be the best (and only) available shell/editor combination available.
When running R in an ordinary terminal window execution can be
terminated with CTRL-C

I hope they will soon fix this (and a small handfull of other
bugs/flaws, mostly missing/wrong keyboard shortcuts) and JGR would
make a huge step from very good to excellent

Bernd

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to stop an R script when running JGR on a Linux/SuSE system

2009-08-01 Thread Bernd Kreuss
sorry for the eventual double posting, but i got a strange error from a
versatel(???) server about not enough quota when replying to the message

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Forumla format?

2009-07-27 Thread Bernd Kreuss
Steve Lianoglou wrote:

 Is it possible to build up your formula as a string, and then convert  
 to formula w/ as.formula?

what about simply using it this way instead:

svm(label ~ ., data=mydata[,-c(22,23,25,31)])

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.