Re: [R] R script to start session (without automatically finishing)

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Thu, 3 Jan 2008 10:01:10 +0000 (GMT)

On Thu, 3 Jan 2008, Philipp Fechteler wrote:

> Hello Mr Ripley
>
> Prof Brian Ripley wrote:
>> So you have to write a script that will not terminate until you 'press a
>> button or something like this'. That's easy to do, but as you haven't told
>> us your OS. E.g. on Windows, call winDialogString at the end.
>>
>
> Thank you for helping. I am running on Linux. But I think the getchar() like
> call should be inside the R script. So is there something like this in R or
> any loadable module, e.g. a function sleeping until a key is pressed and
> returning the key code?

See ?readline, and from Rscript scan("stdin", "", n=1).

You can't do this totally portably: R might not be connected to a terminal (even in interactive use: think ESS). You could also use a Tk widget to give your users a button to press.

>
>
> Greetings
> Philipp
>
>
>> On Fri, 21 Dec 2007, Philipp Fechteler wrote:
>>
>>> Hello R friends
>>>
>>> I am quite impressed by the power of R, I am using it only since some
>>> weeks now. But its visualizing capabilities are outstanding!
>>>
>>> But one thing I couldn't solve: I have programs producing lots of data,
>>> most times 3D. In R I am using the library rgl to visualize nicely the
>>> 3D data.
>>>
>>> What I would like to do is to write R scipts which read in a data file
>>> and show me the 3D rgl plot. So that on the command line I just call my
>>> newly written R script, which pops up the rgl window. This session
>>> should run until I close the rgl window or press a button or something
>>> like this.
>>>
>>> Currently, I can write R scripts
>>> - using Rscript or
>>> - http://tolstoy.newcastle.edu.au/R/help/04/05/0500.html
>>> But both approaches contain the problem that the rgl window pops up for
>>> just a moment, and then the program terminates.
>>>
>>>
>>> Does any body has an idea, what to do? Help would be very appreciated.
>>>
>>> Thank's a lot and ... Marry Christmas + Happy New Year
>>>
>>> Philipp
>>>
>>>
>>> ________________________________________________________________________
>>> Dipl.-Ing. Philipp Fechteler
>>> Department Image Processing
>>> Fraunhofer Institute for Telecommunications
>>> Heinrich-Hertz-Institut (HHI)
>>> Einsteinufer 37
>>> 10587 Berlin, Germany
>>> Phone +49 30 31002 616
>>> Fax +49 30 392 72 00
>>> Email philipp.fechteler_at_hhi.fraunhofer.de
>>> WWW http://iphome.hhi.de/fechteler
>>> ________________________________________________________________________
>>
>>
>
>
>

-- 
Brian D. Ripley,                  ripley_at_stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help_at_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.
Received on Thu 03 Jan 2008 - 10:04:57 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 04 Jan 2008 - 10:30:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive