check if a program is installed

前端 未结 3 521
梦谈多话
梦谈多话 2020-12-19 04:03

I\'m writing a function that uses pandoc in R through the command line. How can I use R to check if pandoc installed (I also assume it would have to be on the path which ma

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-19 04:17

    I don't have pandoc to install , but generally I test if a program is installed like this :

    pandoc.installed <- system('pandoc -v')==0
    

    For example to test if java is installed:

     java.installed <- system('java -version') ==0
    
    java version "1.7.0_10"
    Java(TM) SE Runtime Environment (build 1.7.0_10-b18)
    Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)
    > java.installed
    [1] TRUE
    

提交回复
热议问题