[R-sig-Debian] translation from windows to linux

Christoph Knapp c.knapp at auckland.ac.nz
Wed May 11 05:06:05 CEST 2011


Thanks for that I already came across .Platform$OS.type and use that in my code. It returns "unix" not "Linux" though. Which one would you recommend?
________________________________________
From: r-sig-debian-bounces at r-project.org [r-sig-debian-bounces at r-project.org] on behalf of Lee Hachadoorian [Lee.Hachadoorian+L at gmail.com]
Sent: Wednesday, May 11, 2011 14:36
To: r-sig-debian at r-project.org
Subject: Re: [R-sig-Debian] translation from windows to linux

Looks like zip.unpack is part of a package called winextras, probably
not a safe bet for Linux portability. Also looks like it will be
deprecated as of R 2.13, so probably will need to be replaced in the
Windows code as well.

If you do need to maintain two-way portability (not just "fix" the
Windows source for persistent use in Linux), you can use
switch(Sys.info()["sysname"], …) to call the right function at the right
time. I couldn't get RPostgreSQL compiled for Windows so I would do
this, though eventually I started running a Ubuntu VM on my Windows machine.

sql = "SELECT foo FROM bar;"

switch(Sys.info()["sysname"],
Linux = {
library(RPostgreSQL)
connCurData = dbConnect(dbDriver("PostgreSQL"), dbname="", user="",
password="", host="",port=5432)
dfUi = dbGetQuery(connCurData, sql)
},
Windows = {
library(RODBC)
connCurData = odbcConnect("CUR Data System DSN", readOnlyOptimize=TRUE)
dfUi = sqlQuery(connCurData, sql, stringsAsFactors=FALSE)
close(connCurData)
}
)

--Lee

On 05/10/2011 07:51 PM, Dirk Eddelbuettel wrote:
> On 10 May 2011 at 23:41, Christoph Knapp wrote:
> | Thanks the first question was answered by Mathieu. Let me rephrase the first question. If I have a R script written under windows I encounter sometimes the problem that function names are not the same as in linux. See  zip.unpack which works perfectly under windows but not under linux. Is there a better method to find functions named different in different OS than asking the mailing list?
>
> There are 2000+ function in 'base R'. Most of them are portable. Many of us
> who have been writing portable code know which ones to avoid.
>
> In a first instance, your best best is almost always the builtin-help,
> e.g. help(rnorm) will be the same on all system.
>
> Some things are by their very nature more OS-dependent, but R does a pretty
> good job of abstracting most of it away ....
>
> As for zip.unpack, it would appear that R on Linux does not have it. I see
> zip.file.extract so maybe you can use that.
>
> Dirk
>
>
> | Christoph
> | ________________________________________
> | From: Ross Boylan [ross at biostat.ucsf.edu]
> | Sent: Wednesday, May 11, 2011 11:21
> | To: Christoph Knapp
> | Cc: ross at biostat.ucsf.edu; r-sig-debian at r-project.org
> | Subject: Re: [R-sig-Debian] translation from windows to linux
> |
> | On Tue, 2011-05-10 at 23:02 +0000, Christoph Knapp wrote:
> | > Hi all,
> | > I started recently to use R with linux(ubuntu) but I often get code written under windows or mac.  I have two questions. When I encounter a function which is not in R linux what is the best way to find the right linux function for it? So next time I can help myself. I browsed the web for a long time and could not find anything to the the function
> | >
> | It would be helpful if you could say exactly what the situation is in
> | which you get the error.  You refer to R linux and ask for linux
> | functions, which sounds as if you want an OS leve function call.
> | I think you mean that while in R you have some code that calls a
> | function, and the function is undefined.
> |
> | > zip.unpack.
> | if that's the offending function, where did the code that invoked it
> | come from?
> | >
> | > Thats actually my second question. Does anyone know the right linux function to unzip zip archive in R linux.
> | >
> | > Thanks
> | >
> | > Christoph
> | >
> | >       [[alternative HTML version deleted]]
> | >
> | > _______________________________________________
> | > R-SIG-Debian mailing list
> | > R-SIG-Debian at r-project.org
> | > https://stat.ethz.ch/mailman/listinfo/r-sig-debian
> |
> |
> | _______________________________________________
> | R-SIG-Debian mailing list
> | R-SIG-Debian at r-project.org
> | https://stat.ethz.ch/mailman/listinfo/r-sig-debian
>

--
Lee Hachadoorian
PhD Student, Geography
Program in Earth & Environmental Sciences
CUNY Graduate Center

_______________________________________________
R-SIG-Debian mailing list
R-SIG-Debian at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-debian



More information about the R-SIG-Debian mailing list