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??
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
list.files also lists directories as items, and if you use recursive=T it dives into those directories. There is no simple R way to list just the files in a directory. I use file_list = system('ls -p <target dir> | grep -v /')