Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there features of R that are system-dependent?

My co-workers would like to make sure that our work in R is platform-independent, specifically that code will run on Linux, Mac, and Windows, and that files created on one system will work on other systems.

Since the issue has come up before in my group, I would appreciate a general answer that will make it easier for me to confidently assure my collaborators that there will not be an issue. E.g., it would help to have a reference other than "because (subject matter expert) said so on SO".

  1. Generally, is there a way to know if any features of R are platform-specific (can I assume that this would be stated in a function's help)?
  2. Are there packages or functions that I can be confident will be platform-independent?
  3. Are there types of packages or functions that I should be wary of?

I have previously asked two questions about the cross-platform readability of files created by R: What are the disadvantages of using .Rdata files compared to HDF5 or netCDF? and Are R objects dumped using `dump` readable cross-platform?

like image 498
David LeBauer Avatar asked Jun 01 '12 15:06

David LeBauer


2 Answers

Besides Carl's answer, the obvious way to ensure that your work in platform-independent is to test on all platforms.

Which is precisely what CRAN does with its 3800+ packages, and you have access to logs here.

In short, R really tries hard to be platform-independent, and mostly succeeds. To do so with your code, it is up to you to avoid APIs or tools which introduce dependencies. Look at abstractions like system.file(package="boot") and the functions they use---you can easily abstract file-system "roots", and separators are already taken care of.

like image 173
Dirk Eddelbuettel Avatar answered Oct 06 '22 13:10

Dirk Eddelbuettel


Check cran.r-project.org for package listings. Every package has a page which will tell you if it's passed testing for different operating systems. Further, as you suggested, the help files are pretty explicit about OS dependencies. R is "smart" enough to translate "/" to "\" in pathnames for those poor folks working in Windows. Generally speaking, graphics access is the area most likely to have platform dependencies. Obviously if you system lacks {X11, ImageMagick, ..} you're stuck anyway.

like image 28
Carl Witthoft Avatar answered Oct 06 '22 14:10

Carl Witthoft