Hi, 

I am using RMarkdown in Rstudio and I want to execute commands from a program using  a bash chunk 

    ````{bash} 
    ```

I have a program called samtools on my computer so when I execute it in the chunk, it works. 

    ```{bash}
    samtools 
    ```

When I type :

    ```{bash}
    which samtools 
    ```

The output is that it tells me samtools is located in the  usr/local/bin  directory. 

However, when I execute a program with vcftools , I get an error because Rstudio, does not know where the program is: 
I have it in another directory on my computer.

How do I get Rstudio or Rmarkdown to execute vcftools from the bash chunk? 
Is there a way that I can tell RMarkdown which directory to look  in to find the program? 

For example (something like) :

    ```{bash}
    $vcftools = /Users/m.o.l.s/Programs_For_Bioinformatics/vcftools
    
    ```

or would I have to move all of the programs to usr/bin/local? 

Outside of  Rstudio, I have made aliases to the programs so they work fine on the terminal. 

I made the alias by writing in my .bash_profile

 `alias bcftools=/Users/paths/to/where/the/program/is/installed`

but I added the path to vcftools to my export PATH in the bash profile completely. 

You can use the full path to the tool:

    ```{bash}
    ~/bin/bioinfotools/vcftools
    ```

Returns:

    ## 
    ## VCFtools (0.1.16)
    ## © Adam Auton and Anthony Marcketta 2009
    ## 
    ## Process Variant Call Format files
    ## 
    ## For a list of options, please go to:
    ##  https://vcftools.github.io/man_latest.html
    ## 
    ## Alternatively, a man page is available, type:
    ##  man vcftools
    ## 
    ## Questions, comments, and suggestions should be emailed to:
    ##  vcftools-help@lists.sourceforge.net

On a side note, it seems the RStudio / Rmarkdown bash engine is somewhat broken. This code block hangs at compilation:

    ```{bash in_path}
    samtools view
    ```

Whereas at the command-line, it instantly returns the help:

    Usage: samtools view [options] <in.bam>|<in.sam>|<in.cram> [region ...]
    
    Options:
      -b       output BAM
      -C       output CRAM (requires -T)
      -1       use fast BAM compression (implies -b)
      -u       uncompressed BAM output (implies -b)
      -h       include header in SAM output
      -H       print SAM header only (no alignments)
      -c       print only the count of matching records
      -o FILE  output file name [stdout]
      -U FILE  output reads not selected by filters to FILE [null]
      -t FILE  FILE listing reference names and lengths (see long help) [null]
      -L FILE  only include reads overlapping this BED FILE [null]
      -r STR   only include reads in read group STR [null]
      -R FILE  only include reads with read group listed in FILE [null]
      -q INT   only include reads with mapping quality >= INT [0]
      -l STR   only include reads in library STR [null]
      -m INT   only include reads with number of CIGAR operations consuming
               query sequence >= INT [0]
      -f INT   only include reads with all  of the FLAGs in INT present [0]
      -F INT   only include reads with none of the FLAGS in INT present [0]
      -G INT   only EXCLUDE reads with all  of the FLAGs in INT present [0]
      -s FLOAT subsample reads (given INT.FRAC option value, 0.FRAC is the
               fraction of templates/read pairs to keep; INT part sets seed)
      -M       use the multi-region iterator (increases the speed, removes
               duplicates and outputs the reads as they are ordered in the file)
      -x STR   read tag to strip (repeatable) [null]
      -B       collapse the backward CIGAR operation
      -?       print long help, including note about region specification
      -S       ignored (input format is auto-detected)
          --input-fmt-option OPT[=VAL]
                   Specify a single input file format option in the form
                   of OPTION or OPTION=VALUE
      -O, --output-fmt FORMAT[,OPT[=VAL]]...
                   Specify output format (SAM, BAM, CRAM)
          --output-fmt-option OPT[=VAL]
                   Specify a single output file format option in the form
                   of OPTION or OPTION=VALUE
      -T, --reference FILE
                   Reference sequence FASTA FILE [null]
      -@, --threads INT
                   Number of additional threads to use [0]

