store output of system command into a variable in r

后端 未结 2 1106
说谎
说谎 2020-12-28 11:35

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

相关标签:
2条回答
  • 2020-12-28 12:08

    why not use the corresponding R function?

    a <- list.files()
    b <- list.files(recursive = TRUE)
    

    For more details

    ?list.files
    
    0 讨论(0)
  • 2020-12-28 12:24

    Use intern=TRUE:

    a <- system("ls ", intern = TRUE)
    
    0 讨论(0)
提交回复
热议问题