title: Run psql from R on MacOS : sh: psql: command not found
body: <p>I am trying to run the command line program <code>psql</code> via an R script using the function <code>system()</code>. I want to do so in order to read a <code>.sql</code> file that creates automatically a schema and tables in my database.</p>
  
  <p>This is my command in R, I am on MacOS :</p>
  
  <pre><code>system("psql -h localhost -U postgres -d db_name -f path_to_the_file.sql")
  </code></pre>
  
  <p>that returns in the Rstudio's console :</p>
  
  <pre><code>sh: psql: command not found
  Warning message:
  In system("psql") : error in running command
  </code></pre>
  
  <p>However, <code>psql</code> commands work perfectly fine in my laptop terminal or in the Rstudio's terminal, but I had to edit my bash profile to make them work. Do I have to do the same with some kind of the "Rstudio bash profile" so I will be able to run <code>psql</code> through the script ?</p>
  
  <p>On the other hand, if there is an other way to create tables with a <code>.sql</code> file using <code>RPostgreSQL</code>, I will be happy to use it ! But I haven't found any...</p>
  
  <p>Thanks a lot for your help !!!</p>