[R] windows vs. linux code

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Feb 26 08:35:35 CET 2009


I think what in my experience is the most common causen for R code 
being confined to one platform has not yet been mentioned: it needs a 
package that is only available on one platform: of CRAN/BioC packages 
that is only a small proprtion, but out of 2000 a small proportion is 
still tens.

On Thu, 26 Feb 2009, Ted.Harding at manchester.ac.uk wrote:

> There is one MAJOR issue you will have to watch out for, far more
> likely to turn up than calls like system().

Not in my experience, and definitely not in well-written code. 
Programmers should let users manage devices for themselves.

> This is that, if you want to have two or more plotting windows
> in use at the same time, while the first one is autoatically
> opened by the plot() command, you will have to open additional
> ones explcitily.

This is what dev.new() is for: it is cross-platform.

But if X11() or x11() has been used, that will work on Windows
(although not for all arguments), and has since 1998.

We do occasionally see problems in packaees where exmaples try to 
open a specific device at a specific size: that may simply be 
impossible on the user's machine.

> In Linux, the command is X11() [possibly with paramaters, though
> usually you don't need to bother].
>
> In Windows, it is windows() [ditto].
>
> I run R on Linux, so use the X11() command. However, If I write
> a script which would also be run on a Windows system, I write
> using windows() in the first instance, but with a conditional
> "alias" to X11():
>
> if(length(grep("linux",R.Version()$os))){
>  windows <- function( ... ) X11( ... )
> }
>
> and put this at the beginning of the code file. Then, if the code
> is run on a Windows machine, the function call windows() does the
> Windows thing; but if the code is run on Linux then the above test
> detects that, and defines a function windows() which does the same
> as X11().
>
> Ted.
>
> On 26-Feb-09 01:25:36, Sherri Heck wrote:
>> i am asking if, in general, r code can be written on a linux-based
>> system and then run on a windows-based system.
>>
>> Rolf Turner wrote:
>>>
>>> On 26/02/2009, at 2:08 PM, Sherri Heck wrote:
>>>
>>>> Dear All-
>>>>
>>>> I have been given some Rcode that was written using a Linux OS, but I
>>>> use Windows-based R.  The person that is giving it to me said that it
>>>> needs to run on a Linux system.  Does anyone have any insight and/or
>>>> can
>>>> verify this.  I haven't yet obtained the code, so I haven't been able
>>>> to
>>>> try it yet.
>>>
>>> Despite the knowledge, wisdom, insight, skill, good looks, and other
>>> admirable characteristics of the members of the R-help list, few of
>>> us are skilled in telepathy or clairvoyance.
>>>
>>>     cheers,
>>>
>>>         Rolf Turner
>>>
>>> ######################################################################
>>> Attention:This e-mail message is privileged and confidential. If you
>>> are not theintended recipient please delete the message and notify the
>>> sender.Any views or opinions presented are solely those of the author.
>>>
>>> This e-mail has been scanned and cleared by
>>> MailMarshalwww.marshalsoftware.com
>>> ######################################################################
>>
>> ______________________________________________
>> 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.
>
> --------------------------------------------------------------------
> E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
> Fax-to-email: +44 (0)870 094 0861
> Date: 26-Feb-09                                       Time: 03:58:35
> ------------------------------ XFMail ------------------------------
>
> ______________________________________________
> 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.
>

-- 
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




More information about the R-help mailing list