detecting operating system in R (e.g. for adaptive .Rprofile files)

switch(Sys.info()[['sysname']],
Windows= {print("I'm a Windows PC.")},
Linux  = {print("I'm a penguin.")},
Darwin = {print("I'm a Mac.")})

Since it took me more than a trivial amount of time to sort this out, I thought other would benefit as well.

Regards,

  • Brian

Leave a Comment