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

前端 未结 4 1491
野趣味
野趣味 2020-11-27 04:44

I was wondering how to automatically detect operating system in R, for example to place things in the .Rprofile.

4条回答
  •  情深已故
    2020-11-27 05:28

    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

提交回复
热议问题