[R] building packages for Linux vs. Windows

Gabor Grothendieck ggrothendieck at gmail.com
Sun Feb 10 19:56:58 CET 2008


On Feb 10, 2008 1:20 PM, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
> On 10/02/2008 1:07 PM, 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?
>
> You will find it much easier to build just one package.
>
> You can use .Platform or (for more detail) Sys.info() to find out what
> kind of system you're running on.  Remember that R doesn't just run on
> Linux and Windows:  there's also MacOSX, and other Unix and Unix-like
> systems (Solaris, etc.).

Just to be a bit more definite try this:

 if (.Platform$OS.type == "windows") cat("I am on Windows\n") else
cat("I am not on Windows\n")



More information about the R-help mailing list