[R] Same code on Mac?

Franklin Bretschneider bretschr at xs4all.nl
Thu Sep 1 17:34:51 CEST 2016

Dear Tom Mosca,


> Using a PC I have written the R code for my elementary statistics students.  One of the students has a Mac.  Should the same lines of code work on a Mac?
> Where can the student find support for R on her Mac?  I don't know anything about them, and have never used one.

Some commands are platform-dependent though, such as opening the standard graphics window [quartz() vs windows()].
This needn't be a problem, since in R a script can sense on which platform it is running.
Some years ago I wrote a platform-sensing graphics routine, reproduced below.
This might help to prevent problems with simple graphics demos, and can no doubt be extended to other commands.

Success, and
Best regards,

Franklin Bretschneider
Dept of Biology
Utrecht University
bretschr at xs4all.nl

#  function PIgraph.r
#  Platform-Independent graphics init
#  determines platform (Windows or Mac) then chooses device type
#  F. Bretschneider; 04-08-2009
#  ====================

PIgraph <- function(w,h) if(.Platform$OS.type == "windows") windows(w=w, h=h) else quartz(w=w, h=h)

#  example application
plot(x,y, type = 'o')

More information about the R-help mailing list