I am executing the following command in R :
system("ls ")
I need to store the output of the above command in some R variable. Is there a way to do the same??
🔗 Base system()/system2() R will convert this into the shell command that writes output to a temporary file, such as below. After the command exits with success, R tries to read the file and return the content.
To run an R command, put the cursor on the line of the command and then click the Run button at the top of the file window. Or just press CTRL-Enter.
Use intern=TRUE
:
a <- system("ls ", intern = TRUE)
why not use the corresponding R function?
a <- list.files() b <- list.files(recursive = TRUE)
For more details
?list.files
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With