Re: [R] building packages for Linux vs. Windows

From: John Sorkin <>
Date: Sun, 10 Feb 2008 13:49:24 -0500

On my widows XP computer, W
>From my windows XP system running R 2.6.1:
> version

platform       i386-pc-mingw32             
arch           i386                        
os             mingw32                     
system         i386, mingw32               
major          2                           
minor          6.1                         
year           2007                        
month          11                          
day            26                          
svn rev        43537                       
language       R                           
version.string R version 2.6.1 (2007-11-26)

John Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center
10 North Greene Street
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)

>>> Ted Harding <> 2/10/2008 1:39 PM >>>
On 10-Feb-08 18:07:56, Erin Hodgess wrote:
> Hi R People:
> I sure that this is a really easy question, but here goes:
> I'm trying to build a package that will run on both Linux and Windows.
> However, there are several commands in a section that will be
> different in Linux than they are in Windows.
> Would I be better off just to build two separate packages, please?
> If just one is needed, how could I determine which system is running
> in order to use the correct command, please?
> Thanks in advance,
> Erin

There is the "version" (a list) variable:


# platform       i486-pc-linux-gnu
# arch           i486
# os             linux-gnu
# system         i486, linux-gnu
# status         Patched
# major          2
# minor          4.0
# year           2006
# month          11
# day            25
# svn rev        39997
# language       R

from which you can extract the "os" component:

# [1] "linux-gnu"

I don;t know what this says on a Windows system, but it surely won't mention Linux!

So testing this wil enable you to set a flag, e.g.

Linux<-ifelse(length(grep("linux",version$os))>0, TRUE, FALSE)

if(Linux){window<-function(...) X11(...)} else

         {window<-function(...) windows(...)}

Hoping this helps,

E-Mail: (Ted Harding) <> Fax-to-email: +44 (0)870 094 0861
Date: 10-Feb-08                                       Time: 18:39:29
------------------------------ XFMail ------------------------------

______________________________________________ mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code.

Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}} mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Sun 10 Feb 2008 - 18:52:04 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 Sun 10 Feb 2008 - 19:30:13 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive