title: Platform neutral way to check if a program exists (e.g. pdfcrop) while creating vignette
body: <p>I have a vignette which uses <code>pdfcrop</code>.  </p>
  
  <p>This is not going to be available on every computer or OS: The R maintainers have told me that <code>pdfcrop</code> is on their Debian systems, but apparently not others, for example.  So I'd like to include in the vignette some logic to figure out if this program is available and use it if possible (I'm using <code>knitr</code> to build the vignette and hence <code>knit_hooks$set(crop = hook_pdfcrop)</code> to activate it).  </p>
  
  <p>I know I can use <code>.Platform</code> to get the OS, and if I'm on unix then I can use <code>which pdfcrop</code> via <code>system()</code> to tell me where/if the program is installed, but I don't know how to make this process general for OSX, linux, Windows etc, and I'm not sure how to properly grab the return value of <code>which</code> or the corresponding commands for other platforms.  </p>
  
  <p>Put another way, I'm trying to do something like this <a href="https://stackoverflow.com/questions/11325198/writing-an-r-package-depending-on-differing-packages-per-architecture">question</a> but I'm not checking for <code>R</code> packages, I'm checking for non-R programs.  I'm turning to SO since I have neither the knowledge nor the platforms to check it on.</p>