[R] Same code on Mac?

Jim Lemon drjimlemon at gmail.com
Fri Sep 2 00:38:42 CEST 2016


Sometimes the problem stems from chronic exposure to user interfaces.
Yesterday I prepared some material for a Mac user's presentation and
said,

"This text file tells you the names of the files you need for the presentation"

the response was,

"Can I click on it?"

I deleted all the files in the directory apart from the necessary ones
and crossed my fingers.

Jim


On Fri, Sep 2, 2016 at 1:50 AM, Sarah Goslee <sarah.goslee at gmail.com> wrote:
> R already contains platform-independent code to open a graphics
> device: dev.new()
> The device thus created is specified in options(), but by default is
> appropriate for the current platform.
>
> It's good practice to use this function instead of calling quartz()
> directly so that your code can be run on other systems.
>
> Sarah
>
> On Thu, Sep 1, 2016 at 11:34 AM, Franklin Bretschneider
> <bretschr at xs4all.nl> wrote:
>> Dear Tom Mosca,
>>
>> Re:
>>
>>> 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
>> x=-3:3
>> y=x^2
>> PIgraph(8,6)
>> plot(x,y, type = 'o')
>>
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>
>
>
> --
> Sarah Goslee
> http://www.stringpage.com
> http://www.sarahgoslee.com
> http://www.functionaldiversity.org
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



More information about the R-help mailing list