R – Get Operating System of Computer Programmatically
Platform specific variables can be accessed in R programming language using .Platform
.
.Platform returns a list with details of platform under which R was built.
To access the name of Operating System of this computer, access the OS.type
component of .Platform
list.
The syntax to access OS.type of .Platform is:
</>
Copy
.Platform$OS.type
Example – Get Operating System
In the following example, we shall print the Operating System of this computer.
</>
Copy
> print (.Platform$OS.type)
[1] "windows"
Possible Values of .Platform$OS.type
There are two possible values for .Platform$OS.type. They are:
- windows
- unix
Uses of knowing Operating System programmatically
If the developer knows which Operating System the program is running programmatically, operating system specific R code can be written.
Conclusion
In this R Tutorial, we learned how to find Operating System of the computer programmatically.