Because we can shut down the Windows system by the command shutdown, we may also use the R function shell() to execute the command. For instance, shell("shutdown -s -t 10") will shut down your computer after 10 seconds (DON'T run the code before you have saved and closed all the programs - I'll not be responsible for your data lost!). If you regret doing so, you can execute shell("shutdown -a") immediately.
I'm not sure whether the command is the same under Linux. (AFAIR, it's the same command but with different options?)
We may include this function in the package fun as well:
shutdown = function(wait = 0, timeout = 10) {
Sys.sleep(wait)
# .Platform$OS.type? Windows? Linux?
shell(sprintf("shutdown -s -t %d", timeout))
}
I think this function can be useful when we want our computer to be shut down automatically after a (time-consuming) task.