title: system command ends function before end in R
body: <p>I have created a <code>salmonify</code> function in R which takes all the fastq files in a folder and then runs the <code>salmon quant</code> function in command line one after another using the <code>system</code> function. However, after the <code>system</code> function completes the list successfully, the rest of the <code>salmonify</code> function will not run. ie. it does not print the statement, and if I try nesting the <code>salmonify</code> function in another function (to run it for multiple study folders), it stops at the same place.</p>
  
  <p>I am using a linux ubuntu 18.04. The salmon function is the latest (1.1.0), and R is version is 3.6.</p>
  
  <p>The code is: </p>
  
  <pre><code>salmonify_single = function(hardrive, study, index){
    salmon_file = "salmon quant -i "
    code1= " -l A -r fastq_files/"
    code3 = " -o Salmon/quant/"
    name = paste0(hardrive, "/", study, "_data/fastq_files")
    L = list.files(name)
  
    O = gsub(x = L, pattern = "_1.fastq", replacement = "")
    code4 = O[! duplicated(O)]
  
    lst = as.list(L)
  
    lst3 = list()
  
    for (i in seq_along(lst)) {
      x = lst[[i]]
      lst3[i] = paste0(salmon_file, index, code1, x[1], code3, code4[i])
    }
  
    for (i in lst3) {
      print(i)
    }
  
    fold_name = paste0(hardrive, "/", study, "_data")
    setwd(fold_name)
  
    for (i in lst3) {
      system(i)
    }
    print(paste0("Completed salmonify for ", study))
  }
  </code></pre>
  
  <p>The output for printing the list that will run from </p>
  
  <pre><code>for (i in lst3) {
      print(i)
    }
  </code></pre>
  
  <p>is :</p>
  
  <pre><code>&gt; salmonify_paired("DATA/RNAseq_Analysis3", 
  +                  "dikovskaya", "salmon_index_k31")
  [1] "salmon quant -i salmon_index_k31 -l A -1 fastq_files/SRR2095296_1.fastq -2 fastq_files/SRR2095296_2.fastq -o Salmon/quant/SRR2095296"
  [1] "salmon quant -i salmon_index_k31 -l A -1 fastq_files/SRR2095297_1.fastq -2 fastq_files/SRR2095297_2.fastq -o Salmon/quant/SRR2095297"
  [1] "salmon quant -i salmon_index_k31 -l A -1 fastq_files/SRR2095298_1.fastq -2 fastq_files/SRR2095298_2.fastq -o Salmon/quant/SRR2095298"
  [1] "salmon quant -i salmon_index_k31 -l A -1 fastq_files/SRR2095299_1.fastq -2 fastq_files/SRR2095299_2.fastq -o Salmon/quant/SRR2095299"
  [1] "salmon quant -i salmon_index_k31 -l A -1 fastq_files/SRR2095300_1.fastq -2 fastq_files/SRR2095300_2.fastq -o Salmon/quant/SRR2095300"
  [1] "salmon quant -i salmon_index_k31 -l A -1 fastq_files/SRR2095301_1.fastq -2 fastq_files/SRR2095301_2.fastq -o Salmon/quant/SRR2095301"
  </code></pre>
  
  <p>Then the salmon function begins, and then I can't get it to print <code>Completed salmonify for...</code>. Any help here would be much appreciated.</p>
  
  <p>Best,</p>
  
  <p>James</p>