I am new to bioinformatics, but have been using R for some time. I'd like to use R to run some phylogentic analysis, specifically I want to call Mr. Bayes through the `mrbayes()` wrapper in the `ips` package written and maintained by Christoph Heibl to make reproducible results and easily manageable scripts (for me). I have downloaded the .exe and can work through/interpret tutorial examples with the Mr. Bayes interface. However, when I make block code in R and attempt to run the MCMCs I get an error. How can I get R to properly call Mr. Bayes and allow me to run the MCMCs from within R? See below for my attempt, mostly lifted from the CRAN `ips` vignette. 


        # get some data included in the ips package
         data(ips.cox1)
    
        # truncate the seqences for a quick analysis
        ips <- ips.cox1[, 100:140]
    
        # set the working directory to the .exe location
        setwd("C:/Users/Gregory/Programs/MrBayes/")
    
        # set parameters, create the Mr. Bayes block code, and run the MCMCs
        mrbayes(ips, file = "", ngen = 100, run = TRUE)
    
        ###NEXUS
        
        ###[created by ips on Wed Feb 08 14:57:29 2017]
        
        ###begin data;
        	###dimensions ntax=26 nchar=41;
        	###format datatype=dna missing=N gap=-;
       ### matrix
        ###Ips_avulsus                ctcttagggtttgtagtttgagctcaccacatatttacagt
        ###Ips_confusus               cttctaggctttgtagtatgagcccaccatatattcacagt
        ###Ips_cribricollis           ttattaggatttgtagtatgagcccatcatatattcacagt
        ###Ips_borealis               cttctaggttttgtagtttgagctcatcatatatttacagt
        ###Ips_pilifrons              cttctaggttttgtagtttgagctcatcatatatttacagt
        ###Ips_nitidus                cttttaggatttgtagtatgagcccaccatatatttacagt
        ###Ips_sexdentatus            cttttaggttttgtagtttgagctcaccatatatttaccgt
        ###Ips_hoppingi               cttctaggctttgtagtatgagcccaccatatattcacagt
        ###Ips_perturbatus            cttctaggttttgtagtttgagctcaccatatatttacagt
        ###Ips_acuminatus             cttttaggatttgtggtctgagcacaccacatattcacagt
        ###Ips_apache                 ctacttggatttgtagtctgagctcaccatatattcacagt
        ###Ips_bonanseai              cttttaggatttgtcgtgtgagctcatcatatattcacagt
        ###Ips_cembrae                nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
        ###Ips_duplicatus             agattttggcttcttcccccctctctagccctccttatcat
        ###Ips_typographus            cttttaggatttgtagtatgagctcaccatatatttacagt
        ###Ips_hunteri                cttctaggttttgtagtttgagctcaccatatatttacagt
        ###Ips_shangrila              ctcttaggtttcgtagtttgagctcatcatatatttacagt
        ###Ips_subelongatus           cttttaggcttcgttgtatgagcacatcatatatttacagt
        ###Ips_tridens                cttctaggttttgtagtttgagctcatcatatatttacagt
        ###Ips_amitinus               cttttaggatttgtagtatgagctcaccatatatttaccgt
        ###Orthotomicus_mannsfeldi    nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
        ###Orthotomicus_suturalis     ttattaggatttgtagtttgagctcaccacatatttactat
        ###Orthotomicus_proximus      ctactaggcttcgtagtgtgagcccaccacatattcactgt
        ###Orthotomicus_erosus        cttctgggtttcgtggtgtgggctcaccacatattcaccgt
        ###Pityogenes_bistridentatus  cttctaggatttgtagtttgagcacatcatatatttactat
        ###Pityogenes_trepanatus      ttactaggatttgttgtttgagcccaccatatattcacaat
        ###;
        ###end;
        
        ###begin mrbayes;
        	###lset nst=6 rates=invgamma ngammacat=4;
        	###mcmc nruns=2 ngen=100 printfreq=100 samplefreq=10 nchains=4 savebrlens=yes temp=0.2;
        	###sumt filename= burnin=10 contype=allcompat;
        ###end;

       ###Error in file(file, "r") : cannot open the connection
        ###In addition: Warning messages:
        ###1: running command 'mrbayes .bayes' had status 127 
        ###2: In file(file, "r") :
         ### cannot open file '.con.tre': No such file or directory


I do not know how to interpret the last few lines here. The NEXUS file seems to be made correctly, with all parameters set mostly to default values. I'm not sure what the file "r" is nor what status 127 is. The consensus tree cannot be called because it hasn't been made presumably. 
This is part of the code at the end of `mrbayes()` function:

    if (run) {
      if (.Platform$OS.type == "unix") {
        system(paste("mb > execute", file))
      }
      else {
        system(paste("mrbayes ", file, ".bayes", sep = ""))
      }
      tr <- read.nexus(paste(file, ".con.tre", sep = ""))
      tr
    }

In other words, no special measures are taken to ensure the Mr. Bayes executable can be found. Also, unfortunately, you cannot pass the path to the executable to `mrbayes()`. Make sure you can run Mr. Bayes from the shell command line and add the path to the PATH environmental variable in order to fix it. Alternatively you could set it in R using `Sys.setenv()` and `Sys.getenv()`:

    Sys.setenv(PATH = paste(Sys.getenv("PATH"), "<path-to-mrbayes", sep = ":"))