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]]
See str(version). version$platform or version$os should work for what you're looking for. Cheers, Noah On Feb 25, 2011, at Feb 25 1:23 PM , Hui Du 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.
Hi Hui, May be sessionInfo() is what you are looking for. See ?sessionInfo as well as ?version for more details. You can run the following on your R session and see what comes up: sessionInfo() sessionInfo()$R.version$platform version$platform Then, you might use ifelse() to set up the right path. HTH, Jorge On Fri, Feb 25, 2011 at 1:23 PM, Hui Du <> 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@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. >[[alternative HTML version deleted]]
On Feb 25, 2011, at 12:23 PM, Hui Du 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, > > HXDSee ?.Platform, more specifically: On Unixen (eg. Linux, OSX)> .Platform$OS.type[1] "unix" and on Windows, will be "windows". If needed, look at the additional functions listed in the See Also on the help page (eg. ?Sys.info, etc.). HTH, Marc Schwartz
On Feb 25, 2011, at 1:23 PM, Hui Du 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"?version -- David Winsemius, MD West Hartford, CT
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.
>
--
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org
Great. Thanks. Best Regards, Hui Du Data Ventures Inc -----Original Message----- From: David Winsemius [mailto:dwinsemius at comcast.net] Sent: Friday, February 25, 2011 12:59 PM To: Hui Du Cc: r-help at r-project.org Subject: Re: [R] R in different OS On Feb 25, 2011, at 1:23 PM, Hui Du 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"?version -- David Winsemius, MD West Hartford, CT
Look at Sys.info() -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 2/25/11 10:23 AM, "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.