[R] R in different OS

David Scott d.scott at auckland.ac.nz
Sat Feb 26 12:56:12 CET 2011


Thanks Brian, I stand corrected.

David Scott

On 27/02/2011 12:32 a.m., Prof Brian Ripley wrote:
> It is less clear what you are after, but the canonical way to decide
> if your R session is on Windows is
>
> .Platform$OS.type == "windows"
>
> Unlike {R.}version$os and Sys.info()["sysname"], the set of values
> here is known and documented.  As ?R.version does say:
>
>        Do _not_ use ‘R.version$os’ to test the platform the code is
>        running on: use ‘.Platform$OS.type’ instead.  Slightly different
>        versions of the OS may report different values of ‘R.version$os’,
>        as may different versions of R.
>
>
> On Sun, 27 Feb 2011, David Scott wrote:
>
>> Not sure exactly what the  original poster was after, but for distinguishing
>> when I am working on different machines with different OS, I use something
>> like this:
>>
>> ### Set some state variables
>> opSys<- Sys.info()["sysname"]
>> if (opSys == "Windows"){
>>   linux<- FALSE
>> } else {
>>   linux<- TRUE
>> }
>>
>> David Scott
>>
>> On 26/02/2011 10:00 a.m., Ista Zahn wrote:
>>> Hi,
>>>
>>> see ?R.version
>>>
>>> Something like
>>> if(version$os == "mingw32") {
>>>                  path = "/ABC"} else {
>>>                  path = "/DEF"
>>> }
>>>
>>> might do it, but I'm not sure exactly what possible values version$os
>>> can take or what determines the value exactly.
>>>
>>> Best,
>>> Ista
>>>
>>>
>>> On Fri, Feb 25, 2011 at 1:23 PM, Hui Du<Hui.Du at dataventures.com>   wrote:
>>>> Hi All,
>>>>
>>>>                  I have two Rs, one has been installed in Windows system
>>>> and another one has been installed under UNIX system. Is there any
>>>> environmental variable or function to tell me which R I am using? The
>>>> reason that I need to know it is under different system, the data path
>>>> could be different. I want to do something like
>>>>
>>>> if it is R under Windows
>>>>
>>>>                  path = "/ABC"
>>>> else if it is R under UNIX,
>>>>                  path = "/DEF"
>>>>
>>>> Any idea? Thanks.
>>>>
>>>> Best Regards,
>>>>
>>>> HXD
>>>>
>>>>          [[alternative HTML version deleted]]
>>>>
>>>> ______________________________________________
>>>> 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.
>>>>
>>>
>>>
>>>
>>
>>
>> --
>> _________________________________________________________________
>> David Scott	Department of Statistics
>> 		The University of Auckland, PB 92019
>> 		Auckland 1142,    NEW ZEALAND
>> Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
>> Email:	d.scott at auckland.ac.nz,  Fax: +64 9 373 7018
>>
>> Director of Consulting, Department of Statistics
>>
>> ______________________________________________
>> 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.
>>
>


-- 
_________________________________________________________________
David Scott	Department of Statistics
		The University of Auckland, PB 92019
		Auckland 1142,    NEW ZEALAND
Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
Email:	d.scott at auckland.ac.nz,  Fax: +64 9 373 7018

Director of Consulting, Department of Statistics



More information about the R-help mailing list