Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing an R package that is different per architecture

Tags:

r

32bit-64bit

I am writing an R package in which you can make networks and output them in different file-types. I found the package SVGRTipsDevice which can be used to create SVG pictures containing tooltips and hyperlinks, which I really like. I have included this in my package as one of the options to output in, making it not an essential part of my package, but a part of it nonetheless (one that I want to keep).

The problem now is, that this package is for 32bit users only. Because my package depends on it 64bit users are not able to install it. it seems that I either have to make my package 32bit-only as well or remove the SVG abilities (currently I chose the latter to upload to CRAN, with a link to the full package on my site).

Is there any way to do this differently? Like making the package installable for anyone but only make the SVG functionality available for 32bit users?

like image 999
Sacha Epskamp Avatar asked Jan 10 '11 22:01

Sacha Epskamp


2 Answers

easiest way I can think of is to check Sys.info() for the machine type:

So on my machine:

 Sys.info()["machine"]
 machine 
"x86_64" 

EDIT I believe that tells us the architecture of the hardware, not whether R is 32 or 64 bit. So if a user had 64 bit hardware and was running 32 bit R, the above code would still return x86_64 As Sacha pointed out to me, a better solution is to run:

R.Version()$arch
[1] "x86_64"

So you can see I'm running a 64 bit OS AND I am running the 64 bit version of R.

like image 169
JD Long Avatar answered Nov 15 '22 07:11

JD Long


Packages listed in the Suggests: or Enhances: field of the DESCRIPTION file of your package do not need to be installed on the user's system for your package to be installed, so that 32/64 bit users can install your package. Rather than testing for bit-ness, you might ok <- suppressWarnings(require(SVGToolTips))), maybe in .onLoad or similar.

like image 35
Martin Morgan Avatar answered Nov 15 '22 07:11

Martin Morgan