|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
how can I write code to detect whether the machine is Windows or Linux?Hi R-People:
I use 2 machines: a machine with a Windows XP operating system, and another with a Linux Ubuntu OS. I transport my code between these 2 machines. However, pathnames to data files always need to be "adjusted" to account for the OS that I'm working on. Here is my question: How do I write code to detect whether I'm using the XP or the Linux machine? If I knew this, I could write my code in a way so that I didn't have to adjust path names to data file all the time. I checked the archives... didn't find anything, but perhaps didn't know the right search terms... Thanks for your help, R-community! Please respond to: philipsmith@... Best regards, Phil Smith Duluth, GA ______________________________________________ R-help@... 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. |
|
|
Re: how can I write code to detect whether the machine is Windows or Linux?On 24/07/2008, at 9:53 AM, Philip James Smith wrote: > Hi R-People: > > I use 2 machines: a machine with a Windows XP operating system, and > another with a Linux Ubuntu OS. I transport my code between these 2 > machines. However, pathnames to data files always need to be > "adjusted" to account for the OS that I'm working on. > > Here is my question: > > How do I write code to detect whether I'm using the XP or the Linux > machine? > > If I knew this, I could write my code in a way so that I didn't > have to adjust path names to data file all the time. > > I checked the archives... didn't find anything, but perhaps didn't > know the right search terms... The help for ``version'' says to use .Platform$OS.type to check what platform the code is running on. cheers, Rolf Turner ###################################################################### Attention:\ This e-mail message is privileged and confid...{{dropped:9}} ______________________________________________ R-help@... 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. |
|
|
Re: how can I write code to detect whether the machine is Windows or Linux?on 07/23/2008 04:53 PM Philip James Smith wrote:
> Hi R-People: > > I use 2 machines: a machine with a Windows XP operating system, and > another with a Linux Ubuntu OS. I transport my code between these 2 > machines. However, pathnames to data files always need to be "adjusted" > to account for the OS that I'm working on. > > Here is my question: > > How do I write code to detect whether I'm using the XP or the Linux > machine? > > If I knew this, I could write my code in a way so that I didn't have to > adjust path names to data file all the time. > > I checked the archives... didn't find anything, but perhaps didn't know > the right search terms... > > Thanks for your help, R-community! Please respond to: > philipsmith@... See ?.Platform For example: > .Platform$OS [1] "unix" It's always dangerous to say always, but "in general", the use of: Path/To/File with *forward* slashes, will work on both Windows and Linux, including the use of relative paths. See: http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-file-names-work-in-Windows_003f and http://cran.r-project.org/bin/windows/base/rw-FAQ.html#R-can_0027t-find-my-file for some hints. HTH, Marc Schwartz ______________________________________________ R-help@... 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. |
|
|
Re: how can I write code to detect whether the machine is Windows or Linux?Ryacas is one package that checks this. Look at this file:
http://ryacas.googlecode.com/svn/trunk/R/yacasInstall.R On Wed, Jul 23, 2008 at 5:53 PM, Philip James Smith <philipsmith@...> wrote: > Hi R-People: > > I use 2 machines: a machine with a Windows XP operating system, and another > with a Linux Ubuntu OS. I transport my code between these 2 machines. > However, pathnames to data files always need to be "adjusted" to account for > the OS that I'm working on. > > Here is my question: > > How do I write code to detect whether I'm using the XP or the Linux machine? > > If I knew this, I could write my code in a way so that I didn't have to > adjust path names to data file all the time. > > I checked the archives... didn't find anything, but perhaps didn't know the > right search terms... > > Thanks for your help, R-community! Please respond to: > philipsmith@... > > Best regards, > Phil Smith > Duluth, GA > > ______________________________________________ > R-help@... 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. > ______________________________________________ R-help@... 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. |
|
|
Re: how can I write code to detect whether the machine is Windows or Linux?Marc Schwartz wrote:
> > > It's always dangerous to say always, but "in general", the use of: > > Path/To/File > > with *forward* slashes, will work on both Windows and Linux, including > the use of relative paths. > Also, notice the existence of file.path() and system.file(). (Other separators than forward and backward slashes have been used in the path; e.g. on original MacOS, the colon was used.) -- O__ ---- Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@...) FAX: (+45) 35327907 ______________________________________________ R-help@... 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. |
| Free Forum Powered by Nabble | Forum Help |