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. 

`.bash_profile` is executed when you start a login shell.  My suspicion is that the `bash` R markdown cells are executed in a separate shell instance, that is not a login shell and so this is not executing your `.bash_profile` file when it starts. 

It might be different with `.bashrc`, which might get executed when you start a bash shell in Rmarkdown (or it might not - for example, im pretty sure neither are run on an SGE submission script).

You could try explicitly adding `source ~/.bash_profile` to the start of your code chunk. 
