system in R
In R,
system
invokes the OS command specified by command
.# Now the output of the command will be written to 'stdout'
system_return_val <- system("ls ../")
cat("Retrun value of system is: ", system_return_val, "\n")
## Retrun value of system is: 0
# You can use parameter 'intern' to captur the output of the command as an R character vector
system_return_val <- system("ls ../", intern = TRUE)
cat("Retrun value of system with 'intern=T' is: ", system_return_val, "\n")
## Retrun value of system with 'intern=T' is: donate home post publications_selected tags
intern: a logical (not ‘NA’) which indicates whether to capture the output of the command as an R character vector.
Comments
Post a Comment