I tried to save the results from a System call of an environmental variable in R, following this: store output of system command into a variable in r.
(Note: I am aware i can use: Sys.getenv()
. The call to an environmental variable is just a simplified example to Keep the question "minimal").
OS is Windows 10.
This works:
> system(command = "SET", intern = FALSE)
[1] 127
This does not:
> system(command = "SET", intern = TRUE)
Error in system(command = "SET", intern = TRUE) : 'SET' not found
This works again:
> system(command = "ls", intern = TRUE)
[1] "DESCRIPTION"
[2] "NAMESPACE"
...
Attempts from the suggestions in the comments:
First:
> system(command='echo $SET', intern=TRUE)
[1] "$SET"
Second:
> system(command = "SET", intern = TRUE, ignore.stdout = TRUE)
character(0)
attr(,"status")
[1] 127
Warning messages:
1: In system(command = "SET", intern = TRUE, ignore.stdout = TRUE) :
'SET' not found
2: In system(command = "SET", intern = TRUE, ignore.stdout = TRUE) :
running command 'SET' had status 127